Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to print elements in matrix java

public static void printMatrix(Object[][] matrix){
        for (int i = 0; i < matrix.lenght ; i++) {
            for (int j = 0; j < matrix.lenght; j++) {
                System.out.print(matrix[i][j] + " ");
            }
            System.out.println();
        }
    }
Comment

smart ways to print a matrix in java

//first method::
for(int i=0;i<n;i++)
  	System.out.println(Arrays.toString(matrix[i]));

//second method::

java.util.stream.IntSteam
  				.range(0,n)
  				.forEach(i->System.out.println(Arrays.toString(matrix[i])));

//code by dungriyal
Comment

PREVIOUS NEXT
Code Example
Java :: java list last element 
Java :: java array sorting java8 
Java :: java difference hashmap hashtable 
Java :: minimum and maximum in array in java 
Java :: comparacion de strings java 
Java :: get executable path java 
Java :: read qr code from image java 
Java :: window in java swing 
Java :: initialize hashmap java 
Java :: android bottom navigation hiding views 
Java :: why enable multidex android 
Java :: converting string to int in java 
Java :: main method in java 
Java :: java hash map 
Java :: parcourir un string java 
Java :: java implement interface 
Java :: remove last node from linked list java 
Java :: how to highlight text in android studio 
Java :: call function after specific time java android 
Java :: android get device hieght 
Java :: how to change resource color to int color in android 
Java :: maven skip make-assembly 
Java :: android text change java debounce 
Java :: how to spilt the string with comma in jaav 
Java :: get SecretKey from String 
Java :: thread in java 
Java :: Explain JDK, JRE and JVM? 
Java :: org.springframework.security.oauth2.jwt.JwtEncoder 
Java :: if not java 
Java :: 9999999999999 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =