Java Collection : HashMap - Exercises and Solution


1. Write a Java program to associate the specified value with the specified key in a HashMap

View Solution

2. Write a Java program to count the number of key-value (size) mappings in a map

View Solution

3. Write a Java program to copy all of the mappings from the specified map to another map

View Solution

4. Write a Java program to remove all the mappings from a map

View Solution

5. Write a Java program to check whether a map contains key-value mappings (empty) or not

View Solution

6. Write a Java program to get a shallow copy of a HashMap instance

View Solution

7. Write a Java program to test if a map contains a mapping for the specified key

View Solution

8. Write a Java program to test if a map contains a mapping for the specified value

View Solution

9. Write a Java program to create a set view of the mappings contained in a map

View Solution

10. Write a Java program to get the value of a specified key in a map

View Solution

11. Write a Java program to get a set view of the keys contained in this map

View Solution

12. Write a Java program to get a collection view of the values contained in this map

View Solution

13. Write a Java program to Checking duplicate key insertion in HashMap

View Solution

14. Write a Java program to how to use remove() method in HashMap

View Solution

15. Write a Java program to how to use replace() method in HashMap

View Solution

16. Write a Java Program to get value from HashMap when the key is provided

View Solution

17. Write a Java program to create a HashMap to store Key/Value pair

View Solution

18. Write a Java program to get keys from a HashMap collection

View Solution

19. Write a Java program to get all the values from a HashMap collection

View Solution

20. Write a Java program to get the size of the HashMap collection

View Solution

21. Write a Java program to check whether a HashMap contains a specified Key or not

View Solution

22. Write a Java program to check whether a HashMap contains a specified value or not

View Solution

23. Write a Java program to get the value based on the key from a HashMap collection

View Solution



Basic Programs