SlideShare a Scribd company logo
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

Arrays in c
Arrays in cArrays in c
Arrays in c
vampugani
 
Java Stack Data Structure.pptx
Java Stack Data Structure.pptxJava Stack Data Structure.pptx
Java Stack Data Structure.pptx
vishal choudhary
 
Arrays
ArraysArrays
Array in c++
Array in c++Array in c++
Array in c++
Mahesha Mano
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
moazamali28
 
Array
ArrayArray
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
أحمد محمد
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
Adam Mukharil Bachtiar
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
sandhya yadav
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
Spotle.ai
 
Arrays Basics
Arrays BasicsArrays Basics
Arrays Basics
Nikhil Pandit
 
Array in Java
Array in JavaArray in Java
Array in Java
Shehrevar Davierwala
 
Java arrays
Java arraysJava arrays
Java arrays
Kuppusamy P
 
String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)
Anwar Hasan Shuvo
 
List , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in pythonList , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in python
channa basava
 
Python-List.pptx
Python-List.pptxPython-List.pptx
Python-List.pptx
AnitaDevi158873
 
Java Stack Data Structure.pptx
Java Stack Data Structure.pptxJava Stack Data Structure.pptx
Java Stack Data Structure.pptx
vishal choudhary
 

What's hot (20)

Arrays in c
Arrays in cArrays in c
Arrays in c
 
Java Stack Data Structure.pptx
Java Stack Data Structure.pptxJava Stack Data Structure.pptx
Java Stack Data Structure.pptx
 
Arrays
ArraysArrays
Arrays
 
Array in c++
Array in c++Array in c++
Array in c++
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
 
Array
ArrayArray
Array
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
Arrays Basics
Arrays BasicsArrays Basics
Arrays Basics
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Array in Java
Array in JavaArray in Java
Array in Java
 
Java arrays
Java arraysJava arrays
Java arrays
 
String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)
 
List , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in pythonList , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in python
 
Python-List.pptx
Python-List.pptxPython-List.pptx
Python-List.pptx
 
Java Stack Data Structure.pptx
Java Stack Data Structure.pptxJava Stack Data Structure.pptx
Java Stack Data Structure.pptx
 
String, string builder, string buffer
String, string builder, string bufferString, string builder, string buffer
String, string builder, string buffer
 

Similar to Two-dimensional array in java

Learn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & ArraysLearn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & Arrays
Eng Teong Cheah
 
L10 array
L10 arrayL10 array
L10 array
teach4uin
 
Array
ArrayArray
Arrays In General
Arrays In GeneralArrays In General
Arrays In Generalmartha leon
 
Array in C full basic explanation
Array in C full basic explanationArray in C full basic explanation
Array in C full basic explanation
TeresaJencyBala
 
ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
7array in c#
7array in c#7array in c#
7array in c#
Sireesh K
 
C (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptxC (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptx
rohinitalekar1
 
2D arrays
2D arrays2D arrays
Array in Java
Array in JavaArray in Java
Array in Java
Ali shah
 
Array in Java
Array in JavaArray in Java
Array in Java
Ali shah
 
2D Array
2D Array 2D Array
2D Array
Ehatsham Riaz
 
R data-structures-3
R data-structures-3R data-structures-3
R data-structures-3
Victor Ordu
 
Unit4 Slides
Unit4 SlidesUnit4 Slides
Unit4 Slides
Rakesh Roshan
 
C++ lecture 04
C++ lecture 04C++ lecture 04
C++ lecture 04
HNDE Labuduwa Galle
 
Array in c#
Array in c#Array in c#
Array in c#
Prem Kumar Badri
 
Chapter 13.pptx
Chapter 13.pptxChapter 13.pptx
Chapter 13.pptx
AnisZahirahAzman
 
Array.pptx
Array.pptxArray.pptx
Array.pptx
SwapnaliPawar27
 
Arrays in java (signle dimensional array)
Arrays in java (signle dimensional array)Arrays in java (signle dimensional array)
Arrays in java (signle dimensional array)
Talha mahmood
 

Similar to Two-dimensional array in java (20)

Learn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & ArraysLearn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & Arrays
 
L10 array
L10 arrayL10 array
L10 array
 
Array
ArrayArray
Array
 
Arrays In General
Arrays In GeneralArrays In General
Arrays In General
 
Array in C full basic explanation
Array in C full basic explanationArray in C full basic explanation
Array in C full basic explanation
 
Java arrays
Java arraysJava arrays
Java arrays
 
ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
 
7array in c#
7array in c#7array in c#
7array in c#
 
C (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptxC (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptx
 
2D arrays
2D arrays2D arrays
2D arrays
 
Array in Java
Array in JavaArray in Java
Array in Java
 
Array in Java
Array in JavaArray in Java
Array in Java
 
2D Array
2D Array 2D Array
2D Array
 
R data-structures-3
R data-structures-3R data-structures-3
R data-structures-3
 
Unit4 Slides
Unit4 SlidesUnit4 Slides
Unit4 Slides
 
C++ lecture 04
C++ lecture 04C++ lecture 04
C++ lecture 04
 
Array in c#
Array in c#Array in c#
Array in c#
 
Chapter 13.pptx
Chapter 13.pptxChapter 13.pptx
Chapter 13.pptx
 
Array.pptx
Array.pptxArray.pptx
Array.pptx
 
Arrays in java (signle dimensional array)
Arrays in java (signle dimensional array)Arrays in java (signle dimensional array)
Arrays in java (signle dimensional array)
 

Recently uploaded

Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
MayankTawar1
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Why React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdfWhy React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdf
ayushiqss
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 

Recently uploaded (20)

Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Why React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdfWhy React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdf
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 

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.