62,628
社区成员
发帖
与我相关
我的任务
分享public class PassPrimitiveByValue {
public static void main(String[] args) {
int x = 3;
// invoke passMethod() with
// x as argument
passMethod(x);
// print x to see if its
// value has changed
System.out.println("After invoking passMethod, x = " + x);
}
// change parameter in passMethod()
public static void passMethod(int p) {
p = 10;
}
}After invoking passMethod, x = 3
,
我也分享一个
final int[] a = {1,2,3};
a = new int[]{4,5,6}; 错误
a[0] = 34; 正确

