title: Passing big objecst as parameters in java
body: <p>I have done some research and I found out that in Java, primitive data types are passed by value and <code>Object</code> and <code>Arrays</code> are <em>kind of</em> passed by refernce.</p>
  
  <p>I am not quite sure if I understand exactly, when the variable is passed as refernce and when is it passed as value.</p>
  
  <p>For example if I pass an object to a click listener It is probably passed by reference, right? <strong>But what happens if, I then save the value of that parameter in instance variable</strong> inside click listener? Is the data beeing copied?</p>
  
  <p>I have example code below (with some more questions in comments):</p>
  
  <pre><code>//some big class with lots of arrays
  public class InfoClass{
      private ArrayList&lt;SomeObject&gt; array1; //huge array
      private ArrayList&lt;SomeObject&gt; array2; //huge array
  
      //methods...
  }
  
  //listview menuitem click listener which is applied to all items
  public class ListviewItemClickListener implements View.OnClickListener{
  
      private InfoClass _info; //is this a copy of an object or a reference?
      private MyArrayAdapter _adapter;
  
      public ListviewItemClickListener(InfoClass info, MyArrayAdapter adapter){
          _info = info;
          _adapter = adapter;
      }
  
      @Override
      public void onClick(View view) {
          //do something with info class..
          _adapter.notifyDataSetChanged(); //update adapter
      }
  }
  
  //also:
  //what about this, is this inefficient?
  private class SomeClass{
      public String printValueAndObjectType(Object value, Class type){
          return  value.toString()+" "+type.getName();
      }
      //example call: printValueAndObjectType("value", String.class);
      //is the String.class beeing copied?
  }
  </code></pre>