class Sock2 { String color; public boolean equals(Object o) { return color.equals(((Sock2)o).color); } } class TestSocks { public static void main(String [] args) { Sock2 s1 = new Sock2(); s1.color = "blue"; Sock2 s2 = new Sock2(); s2.color = "blue"; if (s1.equals(s2)) System.out.print("equals "); if (s1 == s2) System.out.print("== "); } } 结果为:()
- A、==
- B、equals
- C、equals ==
- D、无结果输出
正确答案:B
答案解析:有
微信扫一扫手机做题