fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. String line, copyLine;
  13. HashSet<String> words = new HashSet<>();
  14. while ((line = reader.readLine()) != null) {
  15. if (!line.isEmpty()) {
  16. copyLine = line.trim().replaceAll("\\s+", " ");
  17. for (String i : copyLine.split(" ")) {
  18. words.add(i);
  19. }
  20. }
  21. }
  22. for (String j : words) {
  23. System.out.println(j);
  24. }
  25. System.out.println(words.size());
  26. }
  27. }
Success #stdin #stdout 0.07s 48196KB
stdin
                                                  ana



                                                    ana
stdout
ana
1