Passing a string to a function
<p>I would like to ask a really simple question. I am just passing a String object to a function but the result is weird. I supposed that because I am passing an object(by reference) the result should have be " Here" and not "Hello". Why is this happening?</p>

<pre><code>public class MainStr
{

/**
 * @param args
 */
public static void main(String[] args)
{
    String str = "Hello!";
    System.out.println(str);
    changeString(str);
    System.out.println(str);


}

static void changeString(String str)
{
    str=" HERE";
}

}
</code></pre>

<p>Thanks.</p>

<p>EDITED:</p>

<pre><code>public class MainStr
{

String str;
/**
 * @param args
 */
public static void main(String[] args)
{
    MainStr ms = new MainStr();
    ms.str = "Hello!";
    System.out.println(ms.str);
    changeString(ms);
    System.out.println(ms.str);


}

static void changeString(MainStr ms)
{
    ms.str=" HERE";

}

}
</code></pre>

<p><strong>If that is the case then why if I pass it inside a wrapper object is working? The wrapper object it is not by reference?</strong></p>

<p>PS: Why this is working that way? String is an object. Why do I need another wrapper Object to change an OBJECT! What if I want to pass something by reference? Is that possible?</p>
