User u1 = new User("小明");
User u2 = new User("小明");
u1 == u2; // false (new)
String s1 = "小明";
String s2 = "小明";
s1 == s2; // true
User u1 = new User("小明");
User u2 = new User("小明");
u1 == u2; // false (new)
String s1 = "小明";
String s2 = "小明";
s1 == s2; // true
转载于:https://my.oschina.net/glfei/blog/3100667