Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.HashMap;
- import java.util.ArrayList;
- import java.util.Scanner;
- import java.util.Map;
- public class Dictionary10{
- public static void main(String[] args)
- {
- ArrayList<String> words = new ArrayList<String>();
- ArrayList<String> definitions = new ArrayList<String>();
- HashMap<String, String> map = new HashMap<String, String>();
- Scanner sc = new Scanner(System.in);
- System.out.println("Enter a word for a definition.");
- String find = sc.nextLine();
- ////ASSUME BOTH ARRAYLISTS CONTAIN WORDS AND DEFINITIONS
- for(int k = 0; k< words.size(); k++)
- {
- map.put((words.get(k)), (definitions.get(k)));
- }
- for(int l = 0; l<words.size(); l++)
- {
- if((words.get(l).indexOf(find)) != -1)
- {
- System.out.println(find + " : " + map.get(find));
- }
- }
- sc.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement