title: Confused, whether java uses call by value or call by reference when an object reference is passed?
body: <pre><code>public class program1{
  
      public static void main(String args[]){
  
          java.util.Vector vc=new java.util.Vector();
  
          vc.add("111");
          vc.add("222");
  
          functioncall(vc);
  
          vc.add("333");
  
          System.out.println(vc);
  
      }
  
      public static void functioncall(java.util.Vector vc){     
  
          vc=null;    
  
      }
  }
  </code></pre>
  
  <p>The output of above program is [111,222,333]. but, when I run the following program the output is [333]. Confused when we pass an reference , how it works whether it is call by value or call by reference? and why</p>
  
  <pre><code>public class program1{
  
      public static void main(String args[]){
  
          java.util.Vector vc=new java.util.Vector();
  
          vc.add("111");
          vc.add("222");
  
          functioncall(vc);
  
          vc.add("333");
  
          System.out.println(vc);
  
      }
  
      public static void functioncall(java.util.Vector vc){
  
          vc.removeAllElements();  
  
      }
  }
  </code></pre>