Is it possible for us to implement a HashMap with one key and two values. Just as HashMap?
Please do help me, also by telling (if there is no way) any other way to
Another nice choice is to use MultiValuedMap from Apache Commons. Take a look at the All Known Implementing Classes at the top of the page for specialized implementations.
Example:
HashMap> map = new HashMap>()
could be replaced with
MultiValuedMap map = new MultiValuedHashMap();
So,
map.put(key, "A");
map.put(key, "B");
map.put(key, "C");
Collection coll = map.get(key);
would result in collection coll
containing "A", "B", and "C".