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 :: how to create java jframe in eclipse 
Java :: java cast bolean to int 
Java :: regex get string between quotes java 
Java :: spring security default username 
Java :: feignException byteBuffer to string 
Java :: hot to grand achievemnt to player spigot 
Java :: Which package contains the Java Collections Framework? Group of answer choices java.net 
Java :: java taking console input 
Java :: how to download java on mint 
Java :: dreamworks studio recent movies 
Java :: java double 2 decimal 
Java :: java check if sql table exists 
Java :: star pattern in java 
Java :: foreach not applicable to type - binary tree sort 
Java :: table of any number in java 
Java :: how to delete a file in java 
Java :: cannot set char field to null value java 
Java :: android java get current date 
Java :: how to use base64.getdecoder() android 
Java :: java how to center window 
Java :: how to add a keylistener to a jframe 
Java :: border bottom android xml 
Java :: android clear specific sharedpreference value 
Java :: Update UI on main thread Android 
Java :: how to play an audio file in java 
Java :: how to solve simultaneous equations in mathematica 
Java :: how to hide label in bottom menu android studio 
Java :: java code examples 
Java :: How to create an adjacency list representation of a graph, in Java? 
Java :: java get cunnect date time 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =