0
Loop Iterator Hashmap issues
I need to remove from a Hashmap that has 1-26 as Key and A-Z as Value. I need to remove every 3rd starting with B. This is what i did. But it doesnt work public void schlaufe(){ Iterator<Integer> it = alphabet.keySet().iterator(); for(int i = 2;it.hasNext();){ if(i%3 == 0){ it.remove(); } } for(int i = 0; i < alphabet.size();i++){ System.out.println(alphabet.get(i)); } }
3 ответов
+ 3
Hi Sanoj ,
Can you add your output in the question.
🙂 Or you need this output. 👇
Output :
A B C E F H I K L N O Q R T U W X Z
or your Requirement is
A B D E G H J K M N P Q S T V W Y Z
👇
https://code.sololearn.com/cB19OMTJHrOj/?ref=app
+ 2
Sanoj Code is updated.
https://code.sololearn.com/cB19OMTJHrOj/?ref=app
+ 1
the Output should be that :
A B C E F H I K L N O Q R T U W X Z
But the alphabet is the value and not the Key.