public class testobj_important { public static void main(String[] args) { String a = new String("abc"); String b = new String("abc"); System.out.println(a==b); String c = "def"; String d = "def"; System.out.println(c==d); } }
false true
上面是两个不同对象
下面是指向同一常量池的对象(地址值相同)
时间: 2024-12-27 13:09:17