5 Ways to Iterate a Map in Java - Simple and Easy!

Поделиться
HTML-код
  • Опубликовано: 11 сен 2024
  • Do you know there are 5 different ways you can use to write code that iterates a Map in Java Collections framework? In this video, I'm happy to show you these 5 ways to iterate a Map in Java with simple and easy to understand code examples.
    The 5 ways to iterate maps in Java are:
    1. Use while loop on keySet iterator
    2. Use enhanced for loop on keySet
    3. Use enhanced for loop on entrySet
    4. Use forEach with Lambda expression
    5. Use Stream API with forEach on entrySet

Комментарии • 9

  • @Mahmudulhasan-ts5hm
    @Mahmudulhasan-ts5hm 5 месяцев назад

    thanks a lot.

    • @CodeJava
      @CodeJava  5 месяцев назад

      Most welcome!

  • @ajitkumarneeraj9374
    @ajitkumarneeraj9374 5 месяцев назад +1

    Hello Sir, Why are your video getting late sir...Your teaching style is great sir...

    • @CodeJava
      @CodeJava  5 месяцев назад

      it's because i'm busy. I'm trying to publish more regular. Thanks and enjoy!

  • @brasilkai
    @brasilkai 5 месяцев назад

    which way is the most efficient one ?

    • @CodeJava
      @CodeJava  5 месяцев назад

      I think the iterator way, because all other ways will end up using iterator internally.

  • @brazo98
    @brazo98 5 месяцев назад

    🖖🖖🖖💪💪💪😻😻😻Nam Good Morning. Best Dude of the Java Spring Boot Framework

    • @CodeJava
      @CodeJava  5 месяцев назад +1

      Thanks. But this video is not about Spring Boot. it's about Java Collections.

    • @brazo98
      @brazo98 5 месяцев назад

      @@CodeJava Java is in Spring Boot isnt it? Perfect so, far so good 🤣🤣🤣