• Post Reply Bookmark Topic Watch Topic
  • New Topic

HashMap<Integer, Integer> ++ value  RSS feed

 
Mathew Mintalm
Ranch Hand
Posts: 103
Eclipse IDE Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I have HashMap<Integer, Integer>, with 100 numbers inside (1-100 range) where this number is key, and every has its default value which is 0.

Now I'm wondering how can I get for example object from this map, lets say with key 1 and ++ its value? So it would change from 0 to 1 in this case.

Thanks!
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very simple: get the number at the specific index, add 1 to it, and put it back at the same index.
 
Mathew Mintalm
Ranch Hand
Posts: 103
Eclipse IDE Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for answer.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!