Declare a 2D array of integers in Java with 3 rows and 4 columns. Initialize the array with the following values:
1 2 3 4 5 6 7 8 9 10 11 12
Single Choice
Views 43
Answer:
Write a Java program to print all the elements of the array.:
public class Main { public static void main(String[] args) { int[][] array = { {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12} }; for (int i = 0; i < array.length; i++) { for (int j = 0; j < array[i].length; j++) { System.out.print(array[i][j] + " "); } System.out.println(); } } }
Related Articles:
This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.
Join Our telegram group to ask Questions
Click below button to join our groups.