編集の要約なし
編集の要約なし
4行目: 4行目:
ケースを無視して内容が等しいか調べます。投入された文字列が大文字と小文字の区別なしに等しい場合 true を返します。
ケースを無視して内容が等しいか調べます。投入された文字列が大文字と小文字の区別なしに等しい場合 true を返します。


  String msg = "hoge";
  String s1 = "hoge";
  String str = "text";
  String s2 = "text";
   
   
  if (msg.equalsIgnoreCase(str)) {
  if (s1.equalsIgnoreCase(s2)) {
     System.out.println("true");
     System.out.println("true");
  }
  }

2019年6月9日 (日) 11:42時点における版

(String).equalsIgnoreCase [1]
public boolean equalsIgnoreCase(String anotherString)

ケースを無視して内容が等しいか調べます。投入された文字列が大文字と小文字の区別なしに等しい場合 true を返します。

String s1 = "hoge";
String s2 = "text";

if (s1.equalsIgnoreCase(s2)) {
    System.out.println("true");
}