About 249,000 results
Open links in new tab
  1. Converting Iterable to Collection in Java - Baeldung

    Apr 4, 2025 · In this tutorial, we’ll explore different ways to convert an Iterable to a Collection in Java. We’ll start with plain Java solutions, then have a look at the options that the Guava and Apache Commons libraries also provide.

    Missing:

    • Map

    Must include:

  2. How to Iterate Any Map in Java? - GeeksforGeeks

    Apr 18, 2025 · Map.keySet() method returns a Set view of the keys contained in this map and Map.values() method returns a collection-view of the values contained in this map. So, If you need only keys or values from the map, you can iterate over keySet or values using for-each loops.

  3. How to Iterate through Collection Objects in Java?

    Jan 7, 2021 · How to iterate through Collection Objects? Method 1: Using enhanced For loop. Syntax used : Example: Method 2: Using Iterator method. Syntax used : Example: Method 3: Using Simple For loop. Syntax used : Example: Method 4: Using forEach method.

  4. How to use Iterator in Java - Iterator Examples with List, Set, Map

    Jul 18, 2024 · Throughout this article, you’ll learn how to use iterator in the Java Collections framework to traverse elements in collections such as List, Set, Map and Queue. You know, there are several ways to iterate collections in Java, but using iterator is the most basic and original.

  5. collections - What is the easiest way to iterate over all the …

    Feb 25, 2009 · While Joachim Sauer is correct for Java 5, there is a simpler option available starting at Java 10: for (var entry : map.entrySet()) { // Do something with entry.getKey() and entry.getValue(); } and Java 8 introduced: map.forEach((k, v) -> { // Do something with k, v });

  6. 5 Ways to Iterate Collections in Java - CodeJava.net

    Jul 18, 2024 · In this article, I will share with you the following methods which you can use for collection iteration: 1. Using Classic For Loop. 2. Using Iterator. 3. Using Enhanced For Loop. 4. Using forEach method with Lambda Expressions. 5. Using Java Stream API.

  7. Iterate Over a Map in Java - Baeldung

    Dec 16, 2024 · In this tutorial, we’ll look at the different ways of iterating through the entries of a Map in Java and write a benchmark test to determine the most efficient method. Simply put, we can extract the contents of a Map using entrySet (), keySet (), or values (). Since these are all sets, similar iteration principles apply to all of them.

  8. Map Interface in Java - GeeksforGeeks

    Apr 23, 2025 · In Java, the Map Interface is part of the java.util package and represents a mapping between a key and a value. The Java Map interface is not a subtype of the Collections interface. So, it behaves differently from the rest of the collection types. Key Features:

  9. Java Iterable to Collection: A Comprehensive Guide

    In Java, the `Iterable` interface is a foundational component that allows a developer to iterate over a collection of elements. However, there might be situations where you need to convert an `Iterable` to a more specific `Collection` type (like `List`, `Set`, or `Map`).

  10. collection in java and java collection framework - JavaGoal

    Nov 24, 2019 · The Map was introduced after the version of JAVA 1.2, but the collection framework also supports Map interfaces and classes. Java iterable interface. The java iterable interface exists in java.lang package. It is the topmost interface in the collection framework. Each sub-interface extends it directly or indirectly and each class implements it.

  11. Some results have been removed
Refresh