Comment on Tutorial - Multidimensional or arrays of arrays in Java By Abinaya
Comment Added by : Devdyuti
Comment Added at : 2014-11-13 15:12:48
Comment on Tutorial : Multidimensional or arrays of arrays in Java By Abinaya
COPY AND PASTE THIS CODE BEST EXAMPLE OF 2D ARRAY
---------------------------------------------------------------------
import java.util.Scanner;
class TwoDimentionalArray{
public static void main(String args[]){
Scanner sr=new Scanner(System.in);
System.out.println("***CREATE YOUR OWN TWO DYMENTIONAL ARRAY***");
System.out.println("-------------------------------------------");
System.out.println("\n");
System.out.print("ENTER ROWS NUMBER::-->");
int rows=sr.nextInt();
System.out.print("ENTER COLUMN NUMBER::-->");
int cols=sr.nextInt();
int count=0;
System.out.print("ENTER COUNT::-->");
count=sr.nextInt();
int[][] intArray=new int[rows][cols];
//System.out.println("lentgth of intArray[][]="+intArray.length);
for(int i=0;i<intArray.length;i++){
for(int j=0;j<intArray[i].length;j++){
//System.out.println("lentgth of intArray["+i+"]="+intArray[i].length);
intArray[i][j]=count++;
}
}
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
System.out.print(intArray[i][j]+" ");
}
System.out.println("");
}
}
}
View Tutorial
- Data Science
- React Native
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Read a file having a list of telnet commands and execute them one by one using Java
Open a .docx file and show content in a TextArea using Java
Step by Step guide to setup freetts for Java
Of Object, equals (), == and hashCode ()
Using the AWS SDK for Java in Eclipse
DateFormat sample program in Java
concurrent.Flow instead of Observable class in Java
Calculator application in Java
Sending Email from Java application (using gmail)