Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Loop through a 2D array Java

// Program start method.
public static void main(String[] args) {
	String[][] array2D = new String[10][10]; // Create 2D array.

	for (int row = 0; row < array2D.length; row++) { // Loop through the rows in the 2D array.
		for (int col = 0; col < array2D[row].length; col++) { // Loop through the columns in the 2D array.
			array2D[row][col] = "row: " + row + ", column: " + col; // Set the data in the right row and column.
		}
	}
}
Comment

java 2d array for each

public static void main(String[] args) {
	int[][] array = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
  
  	for(int[] count : array) {
    	for(int elem : count) {
          
        	System.out.print(elem + " "); 	//output: 1 2 3 4 5 6 7 8 9 
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: javadoc link to class 
Java :: offsetdatetime to date 
Java :: java compare strings alphabetically 
Java :: change color of action bar android studio 
Java :: java stream order by property 
Java :: java display two dimensional array 
Java :: java date with T 
Java :: bukkit Command sender is player 
Java :: how to import cert from browser into java 
Java :: android studio list of strings 
Java :: string array to arraylist 
Java :: convert int to hex java 
Java :: how to crate an array of integers in java 
Java :: factorial of a number using recursion in java 
Java :: Char in scanner 
Java :: change javahome cmd 
Java :: java add com.google.guava dependancy maven 
Java :: indexoutofboundsexception java 
Java :: execute code after delay java 
Java :: java jframe example 
Java :: concatenate two arrays java 
Java :: arraylist java 
Java :: n queens problem leetcode 
Java :: date format android 
Java :: java replaceall regex 
Java :: java detect new line in string 
Java :: java bukkit double jump 
Java :: how to add two numbers in java 
Java :: odd number in java 
Java :: caused by: java.lang.noclassdeffounderror: org/springframework/boot/configurationprocessor/json/jsonexception 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =