Can you simplify my code? (shows how many poeple liked something like on instagram)
Hi guys, do you think I could change something or simplify this Code somehow? (Java): public Name() { for (int i = 0; i >= 0; i++) { name = sc.nextLine(); if (check(name)==true){ names.add(name); } if (names.size()==0) { System.out.println("No one likes this"); }else{ if (names.size() == 1) { System.out.println(names.get(0) + " likes this"); } else if (names.size() == 2) { System.out.println(names.get(1) + " and " + names.get(0) + " like this"); } else if (names.size() == 3) { System.out.println(names.get(2) + " and " + names.get(1) + " and " + names.get(0) + " like this"); } else { int hinten = names.size() - 2; System.out.println(names.get(names.size() - 1) + ", " + names.get(names.size() - 2) + " and " + hinten + " others like this"); } } } } public boolean check(String name) { for(char c: name.toCharArray()) { if(c>='a'&&c<='z') { continue; } if(c>='A'&&c<='Z') { continue; } if(c=='ä'||c=='ö'||c=='ü'||c=='Ä'||c=='Ö'||c=='Ü'||c=='ß') { continue; } return false; } return true; } }