public class ClassNameHere {
public static void main(String[] args) {
String[] str = new String[2];
str[0] = "Hello";
str[1] = "World";
String test = "God!";
str[1] = test;
test = "Guy!";
System.out.println(str[1]);
}
}
I thought the result should be "Guy!" but actually is "God!". Do the elements in the String[] contain references to Strings? Or just contain the content of Strings directly?