Languages

How to iterate over map in java?

4 points
Asked by:
Root-ssh
6663

I have simple java HashMap from java.util package.

eg:

Map<String, Integer> map = new HashMap<>();
map.put("A", 1);
map.put("B", 2);
map.put("C", 3);

What is the best way I can iterate over all keys and values?

0 answers
Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.