HashMap with multiple values under the same key

0 votes
Is it possible to implement a HashMap with one key and two values. Just as HashMap?
Dec 13, 2018 in Java by Daisy
• 8,120 points
5,255 views

1 answer to this question.

0 votes
  1. Use a map that has a list as the value. Map<KeyType, List<ValueType>>
  2. Create a new wrapper class and place instances of this wrapper in the map. Map<KeyType, WrapperType>
  3. Use a tuple like class (saves creating lots of wrappers). Map<KeyType, Tuple<Value1Type, Value2Type>>
  4. Use mulitple maps side-by-side
answered Dec 13, 2018 by Sushmita
• 6,910 points

Related Questions In Java

0 votes
2 answers

Can we catch multiple exceptions in the same catch clause in Java?

In Java 6 and before versions, we ...READ MORE

answered Aug 10, 2018 in Java by sharth
• 3,370 points
1,184 views
0 votes
0 answers

Ho do I Iterate through a HashMap which contains duplicate values

What is the fastest and the best ...READ MORE

Apr 16, 2018 in Java by Daisy
• 8,120 points
664 views
0 votes
2 answers

Ho do I Iterate through a HashMap which contains duplicate values

for (Map.Entry<String, String> item : params.entrySet()) { ...READ MORE

answered Jul 24, 2018 in Java by samarth295
• 2,220 points
4,790 views
0 votes
1 answer

Sort a Map<Key, Value> by values

This might help solve your problem...!!!! public class ...READ MORE

answered Apr 18, 2018 in Java by Rishabh
• 3,620 points
747 views
+5 votes
4 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,450 points

edited Nov 7, 2018 by Omkar 79,311 views
+1 vote
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,500 points
7,922 views
0 votes
1 answer

What are the differences between getText() and getAttribute() functions in Selenium WebDriver?

See, both are used to retrieve something ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,500 points
16,941 views
0 votes
1 answer

Selenium JARS(Java) missing from downloadable link

Nothing to worry about here. In the ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,500 points

edited Aug 4, 2023 by Khan Sarfaraz 4,358 views
0 votes
2 answers

How can I sort values of a Map in Java using its key

Assuming TreeMap is not good for you ...READ MORE

answered Oct 10, 2018 in Java by Sushmita
• 6,910 points
899 views
+4 votes
3 answers

What are the steps to set Java_home on Windows?

Set Java Home JAVA_HOME = C:\Program Files\Java\jdk1.7.0 [Location ...READ MORE

answered Sep 18, 2018 in Java by Sushmita
• 6,910 points
1,628 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP