複数のキーワードが一致する行があります。キーワード全体が一致する必要があります。
例、
String str = "This is an example text for matching countries like Australia India England";
if(str.contains("Australia") ||
str.contains("India") ||
str.contains("England")){
System.out.println("Matches");
}else{
System.out.println("Does not match");
}
このコードは正常に動作します。ただし、一致するキーワードが多すぎると、線が長くなります。 同じコードを書くエレガントな方法はありますか? ありがとう