I want to parse words in a data structure like
You are looking for multiset(or a bag). Multiset is similar to set but it accepts duplicates.Java library does not come with Multiset implemetation. Google's gauva library has an implementation of Multiset.
Methods on multiset
boolean add(E element): Adds a single occurrence of the specified element to this multiset.
int add(E element, int occurrences): Adds a number of occurrences of an element to this multiset.
boolean contains(Object element): Determines whether this multiset contains the specified element.
int count(Object element):Returns the number of occurrences of an element in this multiset (the count of the element).