I understand that everything is passed by reference in java. But why doesn't it work in this case? I had thought it should print out "Hate" instead of "Love".
class Test {
    static class Str {
        public String str;
        public void set(String str) {
            this.str = str;
        }
    }
    public static void main(String[] args) {
        Str s = new Str();
        String str = "Love";
        s.set(str);
        str = "Hate";
        System.out.println(s.str);
    }
}
 
     
     
     
    