Say we have a bunch of char's: 's', 'w', 'e', 's', 't', 'h'
How can we see if we type a character via (char)scanner.nextLine().charAt(0);
at which places the numbers are(1,2,3,4,5,6). For example, if I type w
I get 2
back, or if I type s
, I get 1
and 4
back.
This is the code I already have:
Scanner letter= new Scanner(System.in);
System.out.print("Type a character:");
char let= letter.nextLine().charAt(0);
char[] word = {'s', 'w', 'a', 'g', 'w' };
System.out.print();