I want to create a hashmap that stores the keywords from a title of a paticular activity object which is currently stored in an arraylist. So for example i have the following activities stored in the array list:
Football game - 1st activity object in arraylist -- So here the keyword football will be linked to the 1st activity object in the arraylist and the word game will be linked to the 1st activity object in the arraylist.
Baseball game - 2nd activity object in the arraylist -- So here the keyword baseball will be linked to the 1st activity object in the arraylist and the word game will now be linked to the 2nd activity object and in the arraylist.
Dinner - 3rd activity object in the arraylist
When the user does a search with the keyword "game", i want the hashmap to link 1 and 2 in the arraylist because they both have the word game. Im not sure if im doing this right below. Is this the way to do it?
private ArrayList activities = new ArrayList();
HashMap<ArrayList<Activity>, String> map = new HashMap<>();
map.put(new ArrayList<Activity>(),keyword );
There will be a loop here to add keywords from a tokenized string into activities.
map.get(activities(i)).add(keyword);
HashMap<ArrayList<Activity>, String> map. The keyword is stored in thevaluepart. Does this sounds right? Woudln't thisHashMap<String, ArrayList<Activity>> mapmake more sense? You could also take a look at Guava Multimap.