String s1="str";equals() は大文字と小文字が区別されます (小文字または大文字):
文字列 s2="str";
if(s1.equals(s2))
System.out.println("両方の文字列が等しい");
String s1="str";この場合、false.
文字列 s2="STR";
if(s1.equals(s2))
System.out.println("両方の文字列が等しい");
String s1="str";
文字列 s2="STR";
if(s1.equalsIgnoreCase(s2))
System.out.println("大文字と小文字の区別。2 つの文字列は等しい");
if("string1".length()=="string2".length()))
System.out.println("string1 と string2 のサイズが等しい");
else if("string1".length()>"string2".length())
System.out.println("string1の方が長い");
else
System.out.println("string2 が長い");
new String("test").equals(new String("test"));//->true"=="演算子はオブジェクトの等価性をテストします:
String s1="trial";実行時に呼び出される substring() や replace() とは異なり、コンパイル中に呼び出されるため、連結は true を返します<>。
文字列 s2="トライアル";
//それらは同じオブジェクトです
s1==s2;-->false
//同じオブジェクトではありません
s1 == "test";-->false
//同じオブジェクトを参照します
"test" == "test";-->true
//連結は単一のオブジェクトと見なされます
"test" == "your"+"t";-->true
//substring() メソッドは新しいオブジェクトを生成します
"test" == "1test".substring(1);-->false
//replace() メソッドは新しいオブジェクトを生成します
"test" == "Test".replace("T", "t");-->false
Please disable your ad blocker and refresh the window to use this website.