public class Test {
public static void main(String[] args) {
System.out.println("return is :" + test1().getClass());
}
public static Integer test1() {
int i = 10;
return i;
}
}
运行结果:return is :class java.lang.Integer
感觉返回的i是个引用还是值???????????????
public class Test {
public static void main(String[] args) {
System.out.println("return is :" + test1());
}
public static int test1() {
int i = 10;
try {
return i;
} catch (Exception e) {
return 0;
} finally {
i = 20;
}
}
}
运行结果:return is :10
这里涉及return问题
public class Test {
public static void main(String[] args) {
System.out.println("return is :" + test1());
}
public static Integer test1() {
Integer i = new Integer(10);
try {
return i;
} catch (Exception e) {
return i;
} finally {
i = new Integer(20);
}
}
}
运行结果:return is :10
return到底是引用还是基本值哈?
本环境是JDK5.0
如果是JDK1.4会怎么样哈?
大家研究哈??