Skip to content

Tag: dictionary

3-Dimension List or Map

I need something like a 3-dimension (like a list or a map), which I fill with 2 Strings and an Integer within a loop. But, unfortunately I don’t know which data structure to use and how. Answer Create an object that encapsulates the three together and add them to an array or List: If you want to insert …

Find element position in a Java TreeMap

I am working with a TreeMap of Strings TreeMap<String, String>, and using it to implement a Dictionay of words. I then have a collection of files, and would like to create a representation of each file in the vector space (space of words) defined by the dictionary. Each file should have a vector represe…

When to use a Map instead of a List in Java?

I didn’t get the sense of Maps in Java. When is it recommended to use a Map instead of a List? Answer Java map: An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value. Java list: An ordered collection (also known as a sequence). The user of this