Wednesday, September 14, 2022

Two Dimensional Arrays in Java

 A simple program to demonstrate two dimensional arrays using Java programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
 

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg

=================================================


Want to support my channel?

GCash Account

Jake Pomperada


09173084360


Paypal

https://paypal.me/jakerpomperada


Patreon

https://www.patreon.com/jakerpomperada


Thank you very much for your support.





Program Listing


import java.util.*;

public class Two_Dimensional {

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println();
         System.out.print("Two Dimensional Arrays in Java\n");
         System.out.println();
System.out.print("Give number of rows: ");
int rows = sc.nextInt();
System.out.print("Give  number of columns: ");
int cols = sc.nextInt();
 
int[][] a = new int[rows][cols];
System.out.println();
System.out.println("Enter " + rows + " X " + cols +" = " +
(rows*cols) + " integers:");
for(int i=0; i<rows; i++)
{
for(int j=0; j<cols; j++)
{
a[i][j] = sc.nextInt();
}
}
System.out.println("Here are those " + (rows * cols) +
" integers in a " + rows + " X " + cols
+ " 2D-array");
System.out.println(Arrays.deepToString(a));
sc.close();
}
}


No comments:

Post a Comment