public class MyClass
{
public static int indexOfAny(String string, char[] array) {
int lowestIndex = -1;
for (char ch : array) {
int index = string.indexOf(ch);
if (index > -1) {
if (lowestIndex == -1 || index < lowestIndex) {
lowestIndex = index;
if (index == 0) {
break;
}
}
}
}
return lowestIndex;
}
public static void main(String[] args)
{
String str = "java programming";
int i = indexOfAny(str, new char[] {'x', 'm', 'y'});
System.out.print(i);
}
}
/*
run:
11
*/