陷阱题目

陷阱1、   int i = 0; int j = i++;  

                       结果:   i=1;j=0   分析 i++:先运算后自增


陷阱2、值传递和引用传递的区别

public class StringDemo {
	public static void main(String[] args) {
		String str = new String("Hello");
		int[] ss = { 1, 1, 3 };
		change(str, ss);
	}


	public static void change(String temp, int[] ss) {
		temp = "World";
		ss[1] = 4;
	}


}
结果:
change前:
Hello
1
change后:
Hello
4


往后会增加内容的    ——2017-10-15

猜你喜欢

转载自blog.csdn.net/pddzming/article/details/78243879