Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.HashMap;
  3. import java.util.ArrayList;
  4. import java.util.Scanner;
  5. import java.util.Map;
  6.  
  7. public class Dictionary10{
  8.  
  9. public static void main(String[] args)
  10. {
  11. ArrayList<String> words = new ArrayList<String>();
  12. ArrayList<String> definitions = new ArrayList<String>();
  13. HashMap<String, String> map = new HashMap<String, String>();
  14.  
  15. Scanner sc = new Scanner(System.in);
  16. System.out.println("Enter a word for a definition.");
  17. String find = sc.nextLine();
  18.  
  19. ////ASSUME BOTH ARRAYLISTS CONTAIN WORDS AND DEFINITIONS
  20.  
  21.  
  22. for(int k = 0; k< words.size(); k++)
  23. {
  24. map.put((words.get(k)), (definitions.get(k)));
  25. }
  26.  
  27. for(int l = 0; l<words.size(); l++)
  28. {
  29. if((words.get(l).indexOf(find)) != -1)
  30. {
  31. System.out.println(find + " : " + map.get(find));
  32. }
  33. }
  34. sc.close();
  35.  
  36.  
  37. }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement