lots of exercises in java... from https://github.com/exercism/java

IsogramChecker.java 688B

12345678910111213141516171819202122232425262728293031
  1. import java.util.HashSet;
  2. import java.util.Set;
  3. import static java.util.Arrays.stream;
  4. import static java.util.stream.Collectors.joining;
  5. class IsogramChecker {
  6. boolean isIsogram(String word) {
  7. Set<Character> charSet = new HashSet<>();
  8. String[] words = word.split(" ");
  9. String newWord = concat(words);
  10. words = newWord.split("-");
  11. newWord = concat(words).toLowerCase();
  12. for (int i = 0; i < newWord.length(); i++) {
  13. charSet.add(newWord.charAt(i));
  14. }
  15. return charSet.size() == newWord.length();
  16. }
  17. private String concat(String[] words) {
  18. return stream(words).collect(joining());
  19. }
  20. }