How can I check in an arraylist for the same String while ignoring cases? Sorry in advance, I'm new at StackOverflow.
NEW EDIT: this is what I did so far with NetBeans at school. Thank You All! So what my teacher wants is the following: /* Ask for names and the entered names have to be sorted without doublets. means if the same name is entered twice, the second one will not appear and added to the arrayList. The first Letter has to be upper cased the rest lower. Additional: even with different input spellings. Example: Mike -> miKE -> Megan -> Lucy -> STOP sout: Lucy, Megan, Mike. Addition_2: sout only multiple entered names. */
ArrayList<String> listednames = new ArrayList<>();
while (true) {
String entry = JOptionPane.showInputDialog("name:");
if (entry == null) {
break;
}
entry = entry.trim();
String firstLetter = entry.substring(0,1).toUpperCase();
String end = entry.substring(1).toLowerCase();
String whole = firstLetter + end;
if (entry.equalsIgnoreCase("stop")) {
break;
}
if (entry.isEmpty()) {
continue;
}
if (listednames.contains(entry)) { // .equalsIgnoreCase wont work with lists
continue;
}
listednames.add(entry);
Collections.sort(listednames);
String namen = listednames.toString();
namen = namen.substring(1, namen.length()-1);
System.out.println(namen);
}