SlideShare a Scribd company logo
4
Most read
10
Most read
12
Most read
Experts Of
Programming
Created By: Anonymous
What is 2-D Array?
• Array of Arrays.
• 2-D array usually represented with rows and columns
2-D Array Declaration
• We can declare 2-D array in following ways
type[][] referencevariable;
or
type referencevariable[][];
For example:
int marks[][];
Each element in the 2-D Array must be the same type.
Creation of 2-D Array
arrayreferencevariable = new type[value][value];
For example :
marks = new int[3][4];
More on 2-D Array Creation
marks = new int[][] // incorrect;
marks= new int[][4] // incorrect;
marks = new int[3][] // correct;
2-D array in form of rows and columns:
marks=new int[3][4];
Initialization of 2-D Array
• After array creation we can initialize the 2-D array like this :
• Arrayvariable[row][column]= value;
• For example lets initialize the marks array :
marks[0][0]=8; marks[0][1]=9; marks[0][2]=10; marks[0][3]=7;
8 9 10 7Row 0
Col 0 Col 1 Col 3 Col 4
12 21 30 7
31 45 10 40
Row 1
Row 2
Col 0 Col 1 Col 2 Col 3
Col 0 Col 1 Col 2 Col 3
marks[1][0]=12; marks[1][1]=21; marks[1][2]=30; marks[1][3]=7;
marks[2][0]=31; marks[2][1]=45; marks[2][2]=10; marks[2][3]=40;
8 9 10 7
12 21 30 7
31 45 10 40
Col 0 Col 2 Col 3Col 1
Row 0
Row 1
Row 2
Now if you want to access any element from 2-D array
System.Out.Println(marks[1][2]);
output = 30
System.Out.Println(marks[0][0]);
output = 8
We can also initialize the array at the time of
array creation
int[][] marks = new int{
{1,2,0,5},
{4,5,1,4},
{7,6,5,9}
}
How we can get array length
marks.length // tell us rows.
marks[0].length // tell us columns.
THANKYOU

More Related Content

PPT
Two dimensional array
Rajendran
 
PDF
Java data types, variables and jvm
Madishetty Prathibha
 
PPTX
Java input
Jin Castor
 
PPTX
2D Array
Ehatsham Riaz
 
PPT
Basic elements of java
Ahmad Idrees
 
PPT
Data types
myrajendra
 
PPTX
Array in c language
home
 
PDF
Command line-arguments-in-java-tutorial
Kuntal Bhowmick
 
Two dimensional array
Rajendran
 
Java data types, variables and jvm
Madishetty Prathibha
 
Java input
Jin Castor
 
2D Array
Ehatsham Riaz
 
Basic elements of java
Ahmad Idrees
 
Data types
myrajendra
 
Array in c language
home
 
Command line-arguments-in-java-tutorial
Kuntal Bhowmick
 

What's hot (20)

PPTX
Strings in Java
Abhilash Nair
 
PDF
Python tuple
Mohammed Sikander
 
PPTX
Arrays in Java
Abhilash Nair
 
PPTX
Array in c++
Mahesha Mano
 
PPTX
Array in c programming
Mazharul Islam
 
PPTX
array of object pointer in c++
Arpita Patel
 
PDF
Python list
Mohammed Sikander
 
PDF
Methods in Java
Jussi Pohjolainen
 
PPTX
Array in c#
Prem Kumar Badri
 
PPTX
Interface in java
PhD Research Scholar
 
PPTX
Introduction to Array ppt
sandhya yadav
 
PPT
Arrays
archikabhatia
 
PPTX
Arrays in java
Arzath Areeff
 
PPT
Java Arrays
Jussi Pohjolainen
 
PDF
Datatypes in python
eShikshak
 
PPTX
String in java
Ideal Eyes Business College
 
PPTX
classes and objects in C++
HalaiHansaika
 
PPT
C++ Arrays
أحمد محمد
 
PPT
9. Input Output in java
Nilesh Dalvi
 
PDF
linked lists in data structures
DurgaDeviCbit
 
Strings in Java
Abhilash Nair
 
Python tuple
Mohammed Sikander
 
Arrays in Java
Abhilash Nair
 
Array in c++
Mahesha Mano
 
Array in c programming
Mazharul Islam
 
array of object pointer in c++
Arpita Patel
 
Python list
Mohammed Sikander
 
Methods in Java
Jussi Pohjolainen
 
Array in c#
Prem Kumar Badri
 
Interface in java
PhD Research Scholar
 
Introduction to Array ppt
sandhya yadav
 
Arrays in java
Arzath Areeff
 
Java Arrays
Jussi Pohjolainen
 
Datatypes in python
eShikshak
 
classes and objects in C++
HalaiHansaika
 
C++ Arrays
أحمد محمد
 
9. Input Output in java
Nilesh Dalvi
 
linked lists in data structures
DurgaDeviCbit
 
Ad

Similar to Two-dimensional array in java (20)

PPTX
Understanding 2D Array with example in programming language c
shbee7935
 
PPTX
2D arrays
Mehedi Hasan Raju
 
PDF
Learn C# Programming - Nullables & Arrays
Eng Teong Cheah
 
PDF
arrays-130116232821-phpapp02.pdf
MarlonMagtibay2
 
PPTX
TwoDArrays which can easily help you understand java 2D arrays.pptx
jeyoco4655
 
PPTX
How to create a two-dimensional array in java
Kavitha S
 
PPTX
arrays.pptx
HarmanShergill5
 
PPTX
OOPs with java
AAKANKSHA JAIN
 
PPT
L10 array
teach4uin
 
PPT
Data Structure Midterm Lesson Arrays
Maulen Bale
 
PPTX
Two dimensional Array
sangrampatil81
 
PPT
Visula C# Programming Lecture 5
Abou Bakr Ashraf
 
PDF
Arrays a detailed explanation and presentation
riazahamed37
 
PDF
Java arrays
Kuppusamy P
 
PPSX
dizital pods session 6-arrays.ppsx
VijayKumarLokanadam
 
PPTX
dizital pods session 6-arrays.pptx
VijayKumarLokanadam
 
PDF
Lecture06 computer applicationsie1_dratifshahzad
Atif Shahzad
 
PPTX
arrays in c# including Classes handling arrays
JayanthiM19
 
PPT
Java: Introduction to Arrays
Tareq Hasan
 
PPTX
13 - opp presentation Pointer to 2d arrays and DMA.pptx
alialmani0512
 
Understanding 2D Array with example in programming language c
shbee7935
 
Learn C# Programming - Nullables & Arrays
Eng Teong Cheah
 
arrays-130116232821-phpapp02.pdf
MarlonMagtibay2
 
TwoDArrays which can easily help you understand java 2D arrays.pptx
jeyoco4655
 
How to create a two-dimensional array in java
Kavitha S
 
arrays.pptx
HarmanShergill5
 
OOPs with java
AAKANKSHA JAIN
 
L10 array
teach4uin
 
Data Structure Midterm Lesson Arrays
Maulen Bale
 
Two dimensional Array
sangrampatil81
 
Visula C# Programming Lecture 5
Abou Bakr Ashraf
 
Arrays a detailed explanation and presentation
riazahamed37
 
Java arrays
Kuppusamy P
 
dizital pods session 6-arrays.ppsx
VijayKumarLokanadam
 
dizital pods session 6-arrays.pptx
VijayKumarLokanadam
 
Lecture06 computer applicationsie1_dratifshahzad
Atif Shahzad
 
arrays in c# including Classes handling arrays
JayanthiM19
 
Java: Introduction to Arrays
Tareq Hasan
 
13 - opp presentation Pointer to 2d arrays and DMA.pptx
alialmani0512
 
Ad

Recently uploaded (20)

PDF
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
PDF
Become an Agentblazer Champion Challenge
Dele Amefo
 
PPTX
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
PPTX
oapresentation.pptx
mehatdhavalrajubhai
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
PPTX
TestNG for Java Testing and Automation testing
ssuser0213cb
 
PDF
Wondershare Filmora 14.5.20.12999 Crack Full New Version 2025
gsgssg2211
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
PPTX
Explanation about Structures in C language.pptx
Veeral Rathod
 
PDF
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
PDF
Build Multi-agent using Agent Development Kit
FadyIbrahim23
 
PDF
Bandai Playdia The Book - David Glotz
BluePanther6
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PDF
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
PPTX
Presentation about variables and constant.pptx
kr2589474
 
PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PDF
Become an Agentblazer Champion Challenge Kickoff
Dele Amefo
 
PDF
Micromaid: A simple Mermaid-like chart generator for Pharo
ESUG
 
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
Become an Agentblazer Champion Challenge
Dele Amefo
 
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
oapresentation.pptx
mehatdhavalrajubhai
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
TestNG for Java Testing and Automation testing
ssuser0213cb
 
Wondershare Filmora 14.5.20.12999 Crack Full New Version 2025
gsgssg2211
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
Explanation about Structures in C language.pptx
Veeral Rathod
 
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
Build Multi-agent using Agent Development Kit
FadyIbrahim23
 
Bandai Playdia The Book - David Glotz
BluePanther6
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
Presentation about variables and constant.pptx
kr2589474
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
Become an Agentblazer Champion Challenge Kickoff
Dele Amefo
 
Micromaid: A simple Mermaid-like chart generator for Pharo
ESUG
 

Two-dimensional array in java

  • 2. What is 2-D Array? • Array of Arrays. • 2-D array usually represented with rows and columns
  • 3. 2-D Array Declaration • We can declare 2-D array in following ways type[][] referencevariable; or type referencevariable[][]; For example: int marks[][]; Each element in the 2-D Array must be the same type.
  • 4. Creation of 2-D Array arrayreferencevariable = new type[value][value]; For example : marks = new int[3][4];
  • 5. More on 2-D Array Creation marks = new int[][] // incorrect; marks= new int[][4] // incorrect; marks = new int[3][] // correct;
  • 6. 2-D array in form of rows and columns: marks=new int[3][4];
  • 7. Initialization of 2-D Array • After array creation we can initialize the 2-D array like this : • Arrayvariable[row][column]= value; • For example lets initialize the marks array :
  • 8. marks[0][0]=8; marks[0][1]=9; marks[0][2]=10; marks[0][3]=7; 8 9 10 7Row 0 Col 0 Col 1 Col 3 Col 4 12 21 30 7 31 45 10 40 Row 1 Row 2 Col 0 Col 1 Col 2 Col 3 Col 0 Col 1 Col 2 Col 3 marks[1][0]=12; marks[1][1]=21; marks[1][2]=30; marks[1][3]=7; marks[2][0]=31; marks[2][1]=45; marks[2][2]=10; marks[2][3]=40;
  • 9. 8 9 10 7 12 21 30 7 31 45 10 40 Col 0 Col 2 Col 3Col 1 Row 0 Row 1 Row 2 Now if you want to access any element from 2-D array System.Out.Println(marks[1][2]); output = 30 System.Out.Println(marks[0][0]); output = 8
  • 10. We can also initialize the array at the time of array creation int[][] marks = new int{ {1,2,0,5}, {4,5,1,4}, {7,6,5,9} }
  • 11. How we can get array length marks.length // tell us rows. marks[0].length // tell us columns.