public static void main(String[] args) {
int a[]={2,4,6,8,10};
System.out.println("在main中a的原地址:"+a);
System.out.println("在mian中原始值:");
print(a);
add(a);
System.out.println("调用add的数值:");
print(a);
}
private static void print(int x[]) {
for (int i=0; i<x.length;i++){
System.out.printf("%3d",x[i]);
}
System.out.println();
}
private static void add(int x[]) {
System.out.println("add中x的地址"+x);
for (int i=0; i<x.length;i++){
x[i] +=1;
}
}
java12.5
最新推荐文章于 2024-09-10 10:21:38 发布