title: Java reference-type in parameter
body: <p>Why doesn't this change the initial object:</p>
  
  <pre><code>public class Foo
  {
   Bar item = new Item(5);
  
   public changeBar(Bar test){
    test = new Item(4);
   }
  
   public run(){
  
    changeBar(item);
  
   }
  }
  </code></pre>
  
  <p>In this case <code>item</code> doesn't get changed. How is this possible? I mean, you're passing the reference as parameter in the method, so I'd say assigning a new value to it, means the initial <code>item</code> would also be changed.</p>
  
  <p>Can someone explain to me how this works. </p>
  
  <p>=======================================</p>
  
  <p>however, my question is the following:</p>
  
  <p>the following does work right?</p>
  
  <pre><code>public changeBar2(Bar test){
   test.parameter = "newValue";
  }
  </code></pre>
  
  <p>I don't see how that's different. </p>