Mastering Java and Spring Boot - Live Course : https://bit.ly/TeluskoJavaLive
For More Queries WhatsApp or Call on : +919008963671


In this lecture we are discussing:
1)what is multidimensional array?
2)Why do we need multidimension array?
3)How to create multidimension array?
4)How to access element of multidimension array?
5)how to use enhanced for loop and simple loop in multidimension array to traverse array element?

#1
what is multidimension array?
-- simple we can say it is array of array

-------------
| 1 | 2 | 3 |
-------------
| 4 | 5 | 6 |
-------------

Above is example of 2-d array which has 2 rows and 3 columns.
-- it seems to look like a bigger array consist two single dimension array.
-- just like we have 3-d array and array might be n-dimension.

#2
Why do we need multidimension array?
-- to solve some matrix problem to solve grid problem

#3
How to create multidimension in java?
-- different Ways to create array in java
a)Literal notation
Literal notation: int [][]arr = {{1, 2, 3},{4,5,6}};
b)Object notation
int [][]nums=new int[2][3];

-- general syntax for object notation:
-- dataType [][]arrayName=new dataType[rows][columns];

#4
how to access element of multidimension array element?
let we create 2d array arr
int [][]arr = {{1, 2, 3},{4,5,6}};
-------------
| 1 | 2 | 3 |
-------------
| 4 | 5 | 6 |
-------------

-- there are two rows whose index are 0,1 and columns are 0,1,2.
-- want to access 2 which are at row 0 and columns 1
-- System.out.println(arr[0][1]); //give 2

simple if you want to access element at ith row and jth column then;
arr[i][j]; //it is value at that position

#5
How to use enhanced for loop

for array name arr:
-- using for loop traverse all element
-- arr.length give number of rows and arr[0].length give number of column in first row
for(int i=0;i arr.length;i++){
for(int j=0;j arr[0].length;j++){
System.out.print(arr[i][j]+" ");
}
System.out.println();
}

using enhanced for loop:
for(int x[]: arr){
for(int y:x){
System.out.print(y+" ");
}
System.out.println();
}

general syntax for enhanced for-loop
for(dataType singleDimension[]: twoDimension){
for(dataType element: singleDimension){
System.out.println(element);
}
}


Github repo : https://github.com/navinreddy20/Javacode.git

Java:- https://bit.ly/JavaUdemyTelusko
Spring:- https://bit.ly/SpringUdemyTelusko

More Learning :

Java :- https://bit.ly/3x6rr0N
Python :- https://bit.ly/3GRc7JX
Django :- https://bit.ly/3MmoJK6

JavaScript :- https://bit.ly/3tiAlHo
Node JS :- https://bit.ly/3GT4liq

Rest Api :-https://bit.ly/3MjhZwt
Servlet :- https://bit.ly/3Q7eA7k
Spring Framework :- https://bit.ly/3xi7buh
Design Patterns in Java :- https://bit.ly/3MocXiq
Docker :- https://bit.ly/3xjWzLA

Blockchain Tutorial :- https://bit.ly/3NSbOkc
Corda Tutorial:- https://bit.ly/3thbUKa
Hyperledger Fabric :- https://bit.ly/38RZCRB

NoSQL Tutorial :- https://bit.ly/3aJpRuc
Mysql Tutorial :- https://bit.ly/3thpr4L

Data Structures using Java :- https://bit.ly/3MuJa7S
Git Tutorial :- https://bit.ly/3NXyCPu

Donation:
PayPal Id : navinreddy20
https://www.telusko.com