I have a String hashset (called "names") and I want to remove from it all the Strings that contains at least one char that isn't a capital letter. I wrote this code and it doesn't work:
Iterator<String> iterator=names.iterator();
while(iterator.hasNext()) {
for (int i=0; i<iterator.next().length(); i++) {
if (iterator.next().charAt(i) < 'A' || iterator.next().charAt(i) > 'Z') {
names.remove(iterator.next());
}
}
}