Advertisement
EXPGamer303

Java Multi-Dimensional Array Visual Table

Dec 4th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. package com.expgamer303.javabasics.arrayStuff;
  2.  
  3. public class TableForMultidimensionalArray {
  4.  
  5.     public static void main(String args[]) {
  6.        
  7.         int myArray[][] = {{1, 2, 3, 4, 5},{6, 7, 8, 9, 10}};
  8.        
  9.         int myArray2[][] = {{30, 31, 32, 33},{43},{4, 5, 6}};
  10.        
  11.         System.out.println("This is the First Array");
  12.        
  13.         display(myArray);
  14.        
  15.         System.out.println("This is the Second Array");
  16.         display(myArray2);
  17.        
  18.     }
  19.    
  20.     public static void display(int x[][]) {
  21.        
  22.         for (int row = 0; row < x.length; row++) {
  23.            
  24.             for (int column = 0; column < x[row].length; column++) {
  25.                
  26.                 System.out.print(x[row][column] + "\t");
  27.                
  28.             }
  29.            
  30.             System.out.println(x);
  31.            
  32.         }
  33.        
  34.     }
  35.    
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement