Hash map contains Key and value.
Set contains a list of values.
To convert Hash map to set, you can either covert Keys of Hash Map to Set or Values of Hash Map to Set
Below is the syntax to convert Hash map Keys and Values to Set
| 'java' | | copy code | | ? |
| 1 | |
| 2 | Map |
| 3 | /* insert some values to Hash map*/ |
| 4 | Set skey= new Set(); |
| 5 | sKey=hmap.keySet(); //convert Keys to Set |
| 6 | Set sVal= new Set(); |
| 7 | sVal=hmap.values(); //convert Values to Set |
| 8 |
Please comment your thoughts regarding the above conversion
Post Footer automatically generated by Add Post Footer Plugin for wordpress.
Incoming search terms:
- convert hashmap to set (7)
- convert map to set in java (2)
- how to convert map to set in java (2)
- tips and tricks in hashmap (1)
- tips and tricks for java hash map set (1)
- Java tricks and tips (1)
- java tips and tricks maps hashmaps set list (1)
- java map convert set (1)
- java convert map to set (1)
- java convert hashmap to set (1)
