#29 Multi Dimensional Array in Java

preview_player
Показать описание
Check out our courses:

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO20 (20% Discount)

Udemy Courses:

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

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
for(int j=0;j arr[0].length;j++){
}
}

using enhanced for loop:
for(int x[]: arr){
for(int y:x){
}
}

general syntax for enhanced for-loop
for(dataType singleDimension[]: twoDimension){
for(dataType element: singleDimension){
}
}

More Learning :

Donation:
PayPal Id : navinreddy20
Рекомендации по теме
Комментарии
Автор

Sir you teach every concept in an Amazing way. It is helping me to understand everything. Thanks a lot sir 🙏😊

ayodhyarode
Автор

You’re such an angel! You helped me so much in understanding my homework.

Abbydups
Автор

Big fan of u Navin sir … fantastic series of java … like u had for python

sarathchandar
Автор

You helped me a lot with my homeworks sir, thank you from Myanmar

cramyboba
Автор

The best explanation ever! Thank you very much.

elikmtl
Автор

creating an object of the Random class could also be done here to do the job:
Random random = new Random();
nums[ i ] [ j ] = random.nesxtInt(); // put the upper limit inside the nextInt bracket if you want an upper limit.

MdKamrulIslam-loxn
Автор

Thank you for this lesson, I have enjoyed it a lot, reminds me of my time in university with C++.

egor_andryushchenko
Автор

What program do you use to draw the diagrams for us? I really like it

sentfromheaven
Автор

Yes, I do as you said after watching.

DarkyBoy-ni
Автор

Normal for loop is better and clear than enhancled for loop

yashaswinihm
Автор

@Telusko, The main array is 3 rows and one column right? I see there is only one column for main array which has 3 arrays. The four columns are of internal arrays right?

emerald
Автор

I think this topic is less used in daliy life purposes

GargeyasaikrishnaChava
Автор

I run array in vs code it gives something main error. But I run in Eclipse it gives output.

praveenr
Автор

What's about if we want to take input from the user?

manavkaneria
Автор

sir why to take random Values teach and insert user given values.

LAVAN-
Автор

broo navin bro thandani thane thane thandane thane thane noo brooo super explanation

vxiggfy
Автор

if you are here then i would have kissed on your head man, you just clarified all the doubts which was there from ages ..

shaikbasha
Автор

Sir can we scanner class to intialise variables

nikilkandula
Автор

How can we ourself initialize the multidimensional array as we do in 1d array

hwqjrmo
Автор

Sir pls give free coupon code for your Udemy course. It's an amazing course and your explanation it just excellent

YoutubeCom-deye