contains elements hashmap in arraylist java -
i have hashmap<integer,arraylist<integer>> h
, arraylist<integer> l
want test if first element in arraylist similar @ first value in hashmap want
(entry<integer, arraylist<integer>> e : hmm.entryset()) { integer key1 = e.getkey(); list<integer> valeur = e.getvalue(); int count = 0; int k = 0; //integer temp : listoperateur; if (valeur.contains(listoperateur)) { count++; } sim.put(key1, count); k++; }
this code can you
iterator i1 = listoperateur.iterator(); (map.entry<integer, arraylist<integer>> e : hmm.entryset()) { //if (e.getvalue() != null) { count = 0; //you can move part method avoid deep nested code (integer mapvalue : e.getvalue()) { // (integer listvalue : listoperateur) { if (mapvalue.equals(listoperateur.get(k))) { count++; // } } } sim.put(e.getkey(), count); k++; // } }
Comments
Post a Comment