java - How could i make HashSet as parameter to the HashMap? -


i have maintain list of indexes each of key value in hashmap. declared hashmap as

hashmap<integer,hashset<integer> hset = new hashset<integer>()> hm = new hashmap<integer,hashset<integer> hset = new hashset<integer>()>(); but above declaration seems not correct. declared as

hashset<integer> hset =  new hashset<integer>(); 

but here problem is,how declare type of objects stored in hashset i,e integer, bacause in above declaration hashset rawtype.

i add more here, need initialize outer map below

hashmap<integer,hashset<integer>> map =  new hashmap<integer,hashset<integer>>(); 

and inner collection

hashset<integer> hset =  new hashset<integer>(); 

and insert values below in map , hash set.

hset.add(1); hset.add(2); map.put(100,hset);   hset =  new hashset<integer>(); hset.add(3); hset.add(4); map.put(101,hset);  

so every time need new instance of hashset put in map.

you can inner hashset using map key used insert.

 hashset<integer> hset=map.get(100); //same map 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -