From my understand objects in java are passed by reference, or to be more exact, the references to objects are passed by value. So, if I declare a string and pass it into a function where I change the value of the string, why doesn't the original string change? For example:
class Thing 
{
    static void func(String x){ x = "new"; }
    public static void main(String [] args)
    {
        String y = "old";
        func(y);
        System.out.print(y);
    }
}
Why is the value of y still "old"?
EDIT: Why does the following set the attribute x of Thing something to 90?
class Thing { int x = 0; 
static void func(Thing t){ t.x = 90; }
public static void main(String [] args){
    Thing something = null;
    something = new Thing();
    func(something);
    System.out.print(something.x);
}
}
 
     
     
     
     
     
     
    