RickyS20_

InputReader

Nov 9th, 2020
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1.  
  2. /**
  3. * Class InputReader melakukan input berupa string dengan nama words.
  4. *
  5. * @author (Ricky S)
  6. * @version1
  7. */
  8.  
  9. import java.util.*;
  10. public class InputReader
  11. {
  12. private Scanner reader;
  13. public InputReader()
  14. {
  15. reader = new Scanner(System.in);
  16. }
  17.  
  18. public HashSet<String> getInput()
  19. {
  20. System.out.print("> ");
  21. String inputLine = reader.nextLine().trim().toLowerCase();
  22.  
  23. String[] wordArray = inputLine.split(" ");
  24. HashSet<String> words = new HashSet<String>();
  25. for(String word : wordArray) {
  26. words.add(word);
  27. }
  28. return words;
  29. }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment