Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

hashmap

Why there is no ConcurrentHashSet against ConcurrentHashMap

September 9, 2022 by Tarik

There’s no built in type for ConcurrentHashSet because you can always derive a set from a map. Since there are many types of maps, you use a method to produce a set from a given map (or map class). Prior to Java 8, you produce a concurrent hash set backed by a concurrent hash map, … Read more

Categories java Tags collections, concurrency, hashmap, hashset, java Leave a comment

How to update a value, given a key in a hashmap?

September 8, 2022 by Tarik

map.put(key, map.get(key) + 1); should be fine. It will update the value for the existing mapping. Note that this uses auto-boxing. With the help of map.get(key) we get the value of corresponding key, then you can update with your requirement. Here I am updating to increment value by 1.

Categories java Tags hashmap, java, key Leave a comment

Iterate through a HashMap [duplicate]

August 20, 2022 by Tarik

If you’re only interested in the keys, you can iterate through the keySet() of the map: Map<String, Object> map = …; for (String key : map.keySet()) { // … } If you only need the values, use values(): for (Object value : map.values()) { // … } Finally, if you want both the key and … Read more

Categories java Tags hashmap, iteration, java, loops Leave a comment
Newer posts
← Previous Page1 … Page28 Page29

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa