刚入门没多久,有些小细节不是很清楚,看代码:
public class Pass {
static int j = 20;
public static void main(String[] args) {
int i = 10;
Pass p = new Pass();
p.method(i);
System.out.println(i + " " + j);
}
public void method (int x){
x = x * 2;
y = y * 2;
}
}运行后x=10不太明白,为什么不是20
public class Pass {
static int j = 20;
public static void main(String[] args) {
int i = 10;
Pass p = new Pass();
p.method(i);
System.out.println(i + " " + j);
}
public void method (int x){
x = x * 2;
y = y * 2;
}
}运行后x=10不太明白,为什么不是20
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货