About 262,000 results
Open links in new tab
  1. java - Iterate through 2 dimensional array - Stack Overflow

    Sep 12, 2014 · In the first block, the inner loop iterates over each item in the row before moving to the next column. In the second block (the one you want), the inner loop iterates over all the …

  2. Java Multi-Dimensional Arrays - GeeksforGeeks

    Apr 23, 2025 · In Two dimensional array the the row is present by the i and the column is present by the j and we can get the element using arr [i] [j] using the nested loop. arr is the name of the …

  3. How to loop over two dimensional array in Java? Example - Blogger

    Aug 8, 2021 · How to loop over two dimensional array in Java? Example. You can loop over a two-dimensional array in Java by using two for loops, also known as nested loop. Similarly to …

  4. Java Multi-Dimensional Arrays - W3Schools

    Loop Through a Multi-Dimensional Array. You can also use a for loop inside another for loop to get the elements of a two-dimensional array (we still have to point to the two indexes):

  5. How to use for loop with two dimensional array in Java

    Dec 29, 2019 · To loop over two dimensional array in Java you can use two for loops. Each loop uses an index. Index of outer for loop refers to the rows, and inner loop refers to the columns. …

  6. Iterating Through 2D Array Java - Coding Rooms

    Oct 5, 2020 · We explored using for loops with one-dimensional arrays. Now let’s jump into nested for loops as a method for iterating through 2D arrays. A nested for loop is one for loop …

  7. How to Iterate Through a 2D Array in Java - HatchJS.com

    In this tutorial, we will discuss four different ways to iterate through a 2D array in Java: Using a for loop; Using an enhanced for loop; Using the `iterator()` method; Using the `forEach()` method; …

  8. 2D Array in Java: Configuring Two-Dimensional Arrays

    Oct 26, 2023 · You can iterate over a 2D array using nested for-each loops. The outer loop iterates over the rows and the inner loop iterates over the columns. Here’s an example:

  9. Java Loop Through an Array - W3Schools

    You can loop through the array elements with the for loop, and use the length property to specify how many times the loop should run. The following example outputs all elements in the cars …

  10. Print a Java 2D Array - Baeldung

    Aug 23, 2024 · The most straightforward method involves using nested loops to iterate through the rows and columns of the 2D array. This method is simple and intuitive, making it an …

Refresh