What is the most simple/efficient way of implementing the following Python code in Java?
if "foo" in ["foo", "bar"]:
print "found."
What is the most simple/efficient way of implementing the following Python code in Java?
if "foo" in ["foo", "bar"]:
print "found."
If you have your data in array use this
String[] strings = {"foo","bar"};
for (String s : strings) {
if (s.equals("foo")) {
System.out.println("found");
break;
}
}