代码:

public static void main(String[] args) {
		Integer[] mm = new Integer[] {14561,1264};
		for (Integer item : mm) {
			item=45;//foreach 循环的变量是被transient 修饰的临时变量,是不可以赋值的
		}
		System.out.println(mm[0]);
		System.out.println(mm[1]);
	}

 结果:

  

14561
1264

  并没有发生改变

 

相关文章: