array_printing_types.java
1 //All the multiple ways to print arrays 2 //Below is Solution 2 (importing Arrays library) 3 import java.util.Arrays; 4 5 public class array_printing_types { 6 public static void main(String[] args) { 7 int array[] = {10, 20, 30, 40, 50, 60}; 8 9 //Solution 1 10 //For Loop 11 // 12 System.out.println("Printing using For Loop: \n"); 13 for(int element: array) { 14 System.out.println(element); 15 } 16 17 System.out.println("\nPrinting using Arrays library"); 18 19 System.out.println(Arrays.toString(array)); 20 21 22 //Printing multidimensional arrays 23 24 System.out.println("\nPrinting Multidimensional arrays"); 25 int[][] array2 = {{1,2}, {3,4}, {5,6}}; 26 27 System.out.println((Arrays.deepToString(array2))); 28 } 29 30 }