java - Modifying value in Hashtable -


hello come problem modifying value in hashtable when 2 keys equal.

i define hashtable,

hashtable<string, integer> hash = new hashtable<string, integer>(); 

and program fills data .put() method.

note: first column represents hex values

08 86 aa 10 ff 330 2a 54 e1 60 

i can check string duplicates if(hash.containskey(string x)){}. if want insert data in hashtable, same string hash.put("aa", 77); dont know how add value in hashtable new value , have hashtable no duplikate strings. means have final hastable looking likewise

08 86 aa 87 ff 330 2a 54 e1 60 

any suggestions?

string yourkey = "aa"; int val = 77; if (hashtable.containskey(yourkey))     val += hashtable.get(yourkey)); hashtable.put(yourkey, val); 

this checks duplicates , if there is, add original value table


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -