Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to print a 2d array in java

for (int row = 0; row < arr.length; row++)//Cycles through rows
{
  for (int col = 0; col < arr[row].length; col++)//Cycles through columns
  {
    System.out.printf("%5d", arr[row][col]); //change the %5d to however much space you want
  }
  System.out.println(); //Makes a new row
}
//This allows you to print the array as matrix
Comment

print 2d array in java

int[][] array = new int[rows][columns];
System.out.println(Arrays.deepToString(array));
Comment

java display two dimensional array

//this way u can print your array row by row

for (int i = 0; i < row; i++){
	for (int j = 0; j < column; j++){
        System.out.println(array[i][j]);
	}
}

//this way u can print your array column by column

for (int i = 0; i < column; i++){
	for (int j = 0; j < row; j++){
		System.out.println(array[i][j]);
	}
}
Comment

printing 2d array in java


public class Sample {
    public static void main(String[] args) {

        String roles[][] = {
                { "admin", "customer", "cashier", "manager" },
                { "Jasmine", "lyka", "marbie", "soleen" },
                { "mama", "papa", "jenilyn", "efren" }
        };
        for (int i = 0; i < roles.length; i++) {
            for (int j = 0; j < roles[i].length; j++) {
                System.out.println(roles[i][j] + " ");
            }
            System.out.println("");
        }
    }

}
Comment

display two dimensional array java

//this way u can print your array row by row

for (int i = 0; i < row; i++){
	for (int j = 0; j < column; j++){
        System.out.println(array[i][j]);
	}
}

//this way u can print your array column by column

for (int i = 0; i < column; i++){
	for (int j = 0; j < row; j++){
		System.out.println(array[i][j]);
	}
}
Comment

PREVIOUS NEXT
Code Example
Java :: how to calculate the amount of months between two dates java 
Java :: how to change background tint color programmatically android 
Java :: android retrofit get @query 
Java :: zip file java 
Java :: java log2 
Java :: Java program to find the sum of first 100 numbers 
Java :: loop list java 
Java :: read file java line 
Java :: android vibrate 
Java :: Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema 
Java :: get certain character from string java 
Java :: java find longest string in list 
Java :: java char to charsequence 
Java :: how to divide two ints and get a double java 
Java :: java reverse linked list 
Java :: java get sub array 
Java :: java import text file into arraylist 
Java :: Fast Lookup of Java 
Java :: android alertdialog setSingleChoiceItems 
Java :: java regex replace all characters before 
Java :: java get year from date 
Java :: How to solve the N queens problem in Java? 
Java :: find minimum number in array java 
Java :: AmazonS3ClientBuilder 
Java :: Java Stack class pop() method 
Java :: how to read a excel file in java 
Java :: char to int 
Java :: android studio pass value to another activity 
Java :: does set automatically get rid of duplicates in java 
Java :: string to byte array java utf-8 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =