Out printed is "Hello world" and not "Good bye world"
String is passed by value and not as a value of the reference.
Did i forgot something ?
Code: Select all
public class TestReference {
static String str = "Hello World";
public static void changeIt(String s) {
s = "Good bye world";
}
public static void main(String[] args) {
changeIt(str);
System.out.println(str);
}
}