小程序的输出结果第一题:Java codepublic class Test1 {public static void changeStr(String str) {str
小程序的输出结果 第一题:
Java code
public class Test1 { public static void changeStr(String str) { str = "welcome"; } public static void main(String[] args) { String str = "1234"; changeStr(str); System.out.println(str); }}
这个输出结果是1234,看解答是了解局部变量,那个变量是局部变量啊?我怎么看都一样啊?
第二题:
Java code
public class Test{ private int i=getValue();//第2行 private int j = 10; int getValue(){ return j; } public static void main(String[] args) { System.out.print(new Test().i);//第9行 }}