Re: About Question com.enthuware.ets.scjp.v6.2.694 :
Posted: Wed Sep 26, 2012 7:21 am
I tried the code snippet.
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 ?
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);
}
}