There are various ways of doing the same thing however I'm looking for most efficient way here.
This is what I'm doing currently but there are going to be 5000+ entries that will all be added to girlNames
. Not sure if its the right approach to do such thing and later compare it against given value.
Also appreciate if someone explain the logic behind why other method is better than this one.
Set<String> girlNames = new HashSet<String>();
girlNames.add("monica");
girlNames.add("ribeka");
girlNames.add("angelina");
String str = "angelina";
if (girlNames.contains(str.toLowerCase())) {
System.out.println("found");
} else {
System.out.println("not found");
}