Getter methods in Java
<p>My query is, can a getter method ever return a wrapper data type? Will it violate the principle of Encapsulation? Why not? Is immutability of classes a part of encapsulation?</p>

<pre><code>public class TestGetter{
private Integer a;
public TestGetter(int _a){
    a = _a;
}
public Integer getA(){
   return a;
      }
 }
</code></pre>

<p>In Some client code:</p>

<pre><code>TestGetter tg  = new TestGetter(5);
Integer corruptX = tg.getA();//This should return the reference
corruptX = null;
</code></pre>

<p>So now 
a = null? </p>

<p>When i run it i dont see a as null.</p>
