/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int i1=0,i2=0,i3=0,i4=0,i5=0;
int k2,k5;
for(int j=0;j<5;j++){
/*
* int i = 0;
i=i++;
这个效果如下:
int temp = i++;//this : temp = 0; i =1(that's:i+1);
i = temp;//this: i =0;
因此: i=i++; 相当于什么都没有做,在有的IDE里,它会告诉你这个代码是废代码! */
i1 =i1++;//means:int i1= i1; i1=i1+1;
k2 =i2++; //means: int k2 =i2;i2=i2+1;
i3++;//means: int temp = i3; i3 = i3 +1;
++i4;//means:i4 = i4+1; int temp = i4;
k5 =++i5;//means:i5=i5+1; int k5= i5
System.out.println(" j = "+j);
System.out.println(" i1="+i1);
System.out.println(" i3 ="+i3);
System.out.println(" i4 ="+i4);
System.out.println(" i2 ="+i2+" k2="+k2);
System.out.println(" i5 ="+i5+" k5="+k5);
}
}
输出结果:
j = 0
i1=0
i3 =1
i4 =1
i2 =1 k2=0
i5 =1 k5=1
j = 1
i1=0
i3 =2
i4 =2
i2 =2 k2=1
i5 =2 k5=2
j = 2
i1=0
i3 =3
i4 =3
i2 =3 k2=2
i5 =3 k5=3
j = 3
i1=0
i3 =4
i4 =4
i2 =4 k2=3
i5 =4 k5=4
j = 4
i1=0
i3 =5
i4 =5
i2 =5 k2=4
i5 =5 k5=5
相关文章: