title: Passing String objects as arguments Java
body: <pre><code>class prog {
  
        static String display(String s)
        {
           s = "this is a test";
           return s;
        }
  
     public static void main(String...args) {
  
       prog p = new prog();
       String s1 = "another";
       System.out.println(display(s1)); //Line 1
       System.out.println(s1);
     }
  }
  </code></pre>
  
  <p>A newbie question.</p>
  
  <p>Can someone explain why s1 is not getting updated to "this is a test" ?.</p>
  
  <p>I thought in Java, object arguments are passed as references and if that is the case, then I am passing String <code>s1</code> object as reference in Line 1.</p>
  
  <p>And <code>s1</code> should have been set to "this is a test" via <code>display()</code> method..  Right ?</p>