请问为什么在第一个程序中可以出现输出不同值,但是第二个程序不行?
class Ref1{
int temp=10;
}
public class ClassDemo05 {
public static void main(String[] args) {
Ref1 ref1=new Ref1();
ref1.temp=20;
System.out.println(ref1.temp);
tell(ref1);
System.out.println(ref1.temp);
}
public static void tell(Ref1 ref2) {
ref2.temp=30;
}
}
public class ClassDemo07 {
public static void main(String[] args) {
int a=10;
System.out.println(a);
tell(a);
System.out.println(a);
}
public static void tell(int b) {
b =30;
}
}
临摹微笑
神不在的星期二
喵喔喔
随时随地看视频慕课网APP