Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Java 2D array loop

// 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 :: shell sort java 
Java :: create new java swing button 
Java :: android get text from string xml programmatically 
Java :: string array to arraylist 
Java :: java how to find the largest number in an arraylist 
Java :: char array to string java 
Java :: random word java 
Java :: java game 
Java :: Java Hashmap Access Elements 
Java :: solid principles in programming 
Java :: java int to string 
Java :: how to initialise array in java without size 
Java :: how to create a circle in java 
Java :: how to access variable from another class in java 
Java :: how to add elements in array in java using for loop 
Java :: java loop hashmap 
Java :: intent filter 
Java :: jsonarray to list java 
Java :: android sharedpreferences 
Java :: putting scanner into an array 
Java :: jframe border 
Java :: java load image 
Java :: remove fragment from backstack 
Java :: hide elements android 
Java :: spring boot docker 
Java :: how to summon lightning in minecraft 
Java :: android list index 
Java :: java does file exist 
Java :: java srting array to string 
Java :: set size button java 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =