陷阱题目

来源:互联网 发布:tcp和udp的默认端口 编辑:程序博客网 时间:2024/05/17 08:50

陷阱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前:Hello1change后:Hello4


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

原创粉丝点击