package head;
public class Mix4_90 {
int counter=0;
public static void main(String []args) {
int count=0;
Mix4_90 [] m4a=new Mix4_90[20];
int x=0;
while(x<9) {
m4a[x]=new Mix4_90();
m4a[x].counter=m4a[x].counter+1;
count=count+1;
count=count+m4a[x].maybeNew(x);
x=x+1;
}
System.out.println(count+" "+m4a[1].counter);
}
public int maybeNew(int index) {
if(index<5) {
Mix4_90 m4=new Mix4_90();
m4.counter=m4.counter+1;
return 1;
}
return 0;
}
}
跑出来的结果是 14 1
我想请问m4a[1].counter的值为什么是1呢?我自己看程序以为会是4.