/* == 演算子でオブジェクトを比べる例 */ class Foo { public static void main (String[] args) { String s1 = new String("Hello"); String s2 = s1; String s3 = new String("Hello"); System.out.println(s1==s2); // 同じ参照先か? System.out.println(s1==s3); System.out.println(s1.equals(s3)); // 同じ値(文字列)か? } }