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)); } }

9th Jan 2021, 4:06 PM
Manfred h
3 Respostas
+ 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
10th Jan 2021, 8:02 AM
P∆WAN M∆URY∆
P∆WAN M∆URY∆ - avatar
10th Jan 2021, 2:43 PM
P∆WAN M∆URY∆
P∆WAN M∆URY∆ - avatar
+ 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.
10th Jan 2021, 12:55 PM
Manfred h