重複の可能性:
Java で文字列を比較するにはどうすればよいですか?
class StringTest {
public static void main(String[] args) {
String str1 = "Hi there";
String str2 = new String("Hi there");
System.out.println(str1 == str2);
System.out.println(str1.equals(str2));
}
出力が出てきます:
False
true
str1 と str2 が等しいように見えても、最初の出力が false になるのはなぜですか?