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 parse boolean to string 
Java :: android essential plugin missing 
Java :: random string method java 
Java :: how to set scroll to bottom jscrollpane 
Java :: how to force garbage collection in java 
Java :: The shrinker may have failed to optimize the Java bytecode. To disable the shrinker, pass the `--no-shrink` flag to this command. 
Java :: reduce opacity of image in imageview in android 
Java :: internet access android manifest 
Java :: Exit program Android 
Java :: java double to string with comma 
Java :: InetAddress.getByAddress example 
Java :: java remove first digit from int 
Java :: remove last character from string java 
Java :: java lombok constructor inject guice 
Java :: CellStyle change backgroung color java 
Java :: where is java installed in ubuntu 
Java :: How to find the fibonacci of an integer value iteratively in Java? 
Java :: spring security default username 
Java :: Which package contains the Java Collections Framework? Group of answer choices java.net 
Java :: java reduce sum 
Java :: how to change a bukit chat format 
Java :: java ee service formparam optional 
Java :: java replace whitespace 
Java :: how to delete a file in java 
Java :: ISO week date java 
Java :: string to localdate in java 
Java :: assertthat code throws exception 
Java :: java console colors 
Java :: java only close socket outputstream 
Java :: Update UI on main thread Android 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =