I'm doing a project were I need to remove letters systematically from an ArrayList
as they show up in the words that the user puts in. Then all the remaining characters are displayed and then the elimination process continues until only vowels are left.
I cant seem to get it to eliminate the characters without the program crashing.
Here's the problematic code:
public static void Mapper(){
Scanner make = new Scanner(System.in);
char Aphabets[] ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
ArrayList<Character> Alpabets = new ArrayList<>();
String word = make.nextLine();
for (int i = 0; i < Aphabets.length; i++) {
Alpabets. add(i,Aphabets[i]);
}
for (int i = 0; i < word.length(); i++) {
Alpabets.remove(word.charAt(i));
}
System.out.println(Alpabets);
}
A
is a letter, andR
is a letter. The whole set of 26 letters is (one example of) an alphabet.