I am trying to get my string letters to show me the index for every letter given as input. For example when I input a
it returns 0 which is the index. Currently if I input a word with letter a
and b
it wont return anything. But it should return 0 and 1.
String[] code = {"a", "b","c", "d", "e"};
String letters=input.nextLine();
for (int i=0;i<code.length;i++) {
if (letters.equals(code[i])) {
System.out.print(i);
}
}