SlideShare a Scribd company logo
4
Most read
8
Most read
10
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

What's hot (20)

PPT
Java Arrays
Jussi Pohjolainen
 
PPTX
Two dimensional arrays
Neeru Mittal
 
PPT
Array in Java
Shehrevar Davierwala
 
PPTX
Arrays in Data Structure and Algorithm
KristinaBorooah
 
PDF
Arrays in python
moazamali28
 
PPTX
Array in c#
Prem Kumar Badri
 
PPTX
String, string builder, string buffer
SSN College of Engineering, Kalavakkam
 
PPTX
Java input
Jin Castor
 
PPTX
Constructor in java
Pavith Gunasekara
 
PDF
Class and Objects in Java
Spotle.ai
 
PPT
Queue Data Structure
Lovely Professional University
 
PPT
Abstract class in java
Lovely Professional University
 
PDF
Arrays In Python | Python Array Operations | Edureka
Edureka!
 
PDF
Constructors and Destructors
Dr Sukhpal Singh Gill
 
PPTX
Arrays in c
CHANDAN KUMAR
 
PPTX
Constructor in java
Madishetty Prathibha
 
PPTX
Arrays in Java
Abhilash Nair
 
PPTX
Datastructures in python
hydpy
 
PPTX
2- Dimensional Arrays
Education Front
 
PPT
9. Input Output in java
Nilesh Dalvi
 
Java Arrays
Jussi Pohjolainen
 
Two dimensional arrays
Neeru Mittal
 
Array in Java
Shehrevar Davierwala
 
Arrays in Data Structure and Algorithm
KristinaBorooah
 
Arrays in python
moazamali28
 
Array in c#
Prem Kumar Badri
 
String, string builder, string buffer
SSN College of Engineering, Kalavakkam
 
Java input
Jin Castor
 
Constructor in java
Pavith Gunasekara
 
Class and Objects in Java
Spotle.ai
 
Queue Data Structure
Lovely Professional University
 
Abstract class in java
Lovely Professional University
 
Arrays In Python | Python Array Operations | Edureka
Edureka!
 
Constructors and Destructors
Dr Sukhpal Singh Gill
 
Arrays in c
CHANDAN KUMAR
 
Constructor in java
Madishetty Prathibha
 
Arrays in Java
Abhilash Nair
 
Datastructures in python
hydpy
 
2- Dimensional Arrays
Education Front
 
9. Input Output in java
Nilesh Dalvi
 

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
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PPT
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
PPTX
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
PPTX
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
PDF
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
PPTX
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
Ad

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.