#29 Multi Dimensional Array in Java

  Рет қаралды 133,894

Telusko

Telusko

Жыл бұрын

Check out our courses:
Spring and Microservices Weekend Live Batch : bit.ly/spring-live-weekend
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : bit.ly/java-spring-cloud
Udemy Courses:
Java:- bit.ly/JavaUdemyTelusko
Spring:- bit.ly/SpringUdemyTelusko
Java For Programmers:- bit.ly/javaProgrammers
For More Queries WhatsApp or Call on : +919008963671
website : courses.telusko.com/
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 : github.com/navinreddy20/Javac...
Java:- bit.ly/JavaUdemyTelusko
Spring:- bit.ly/SpringUdemyTelusko
More Learning :
Java :- bit.ly/3x6rr0N
Python :- bit.ly/3GRc7JX
Django :- bit.ly/3MmoJK6
JavaScript :- bit.ly/3tiAlHo
Node JS :- bit.ly/3GT4liq
Rest Api :-bit.ly/3MjhZwt
Servlet :- bit.ly/3Q7eA7k
Spring Framework :- bit.ly/3xi7buh
Design Patterns in Java :- bit.ly/3MocXiq
Docker :- bit.ly/3xjWzLA
Blockchain Tutorial :- bit.ly/3NSbOkc
Corda Tutorial:- bit.ly/3thbUKa
Hyperledger Fabric :- bit.ly/38RZCRB
NoSQL Tutorial :- bit.ly/3aJpRuc
Mysql Tutorial :- bit.ly/3thpr4L
Data Structures using Java :- bit.ly/3MuJa7S
Git Tutorial :- bit.ly/3NXyCPu
Donation:
PayPal Id : navinreddy20
www.telusko.com

Пікірлер: 40
@ayodhyarode4522
@ayodhyarode4522 10 ай бұрын
Sir you teach every concept in an Amazing way. It is helping me to understand everything. Thanks a lot sir 🙏😊
@sarathchandar5047
@sarathchandar5047 Жыл бұрын
Big fan of u Navin sir … fantastic series of java … like u had for python
@Abbydups
@Abbydups Жыл бұрын
You’re such an angel! You helped me so much in understanding my homework.
@ravinduwellalage
@ravinduwellalage Жыл бұрын
ayoo ayoo
@cramyboba1013
@cramyboba1013 Жыл бұрын
You helped me a lot with my homeworks sir, thank you from Myanmar
@elikmtl7730
@elikmtl7730 Жыл бұрын
The best explanation ever! Thank you very much.
@praveenr7957
@praveenr7957 Жыл бұрын
I run array in vs code it gives something main error. But I run in Eclipse it gives output.
@sentfromheaven00
@sentfromheaven00 9 ай бұрын
What program do you use to draw the diagrams for us? I really like it
@egor_andryushchenko
@egor_andryushchenko 6 ай бұрын
Thank you for this lesson, I have enjoyed it a lot, reminds me of my time in university with C++.
@user-ur8rr2uz7z
@user-ur8rr2uz7z 4 ай бұрын
после активации бота, подскажите, как можно включить текущую сетку? не могу что то найти кнопку
@DarkyBoy-n1i
@DarkyBoy-n1i 2 күн бұрын
Yes, I do as you said after watching.
@MdKamrulIslam-lo9xn
@MdKamrulIslam-lo9xn 4 ай бұрын
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.
@manavkaneria
@manavkaneria 10 ай бұрын
What's about if we want to take input from the user?
@emerald8743
@emerald8743 Ай бұрын
@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?
@LAVAN-2424
@LAVAN-2424 6 ай бұрын
sir why to take random Values teach and insert user given values.
@yashaswinihm4288
@yashaswinihm4288 6 ай бұрын
Normal for loop is better and clear than enhancled for loop
@samantsrivastava8170
@samantsrivastava8170 5 ай бұрын
Yes
@shenbagamr421
@shenbagamr421 Жыл бұрын
Nice teaching nallave puriyuthu bro❣️
@sindhisajadali610
@sindhisajadali610 Жыл бұрын
Sir that's best Collection of lectures Plz share Assimignment or H. W It's easy way to students understand and do H. W
@GargeyasaikrishnaChava
@GargeyasaikrishnaChava 5 ай бұрын
I think this topic is less used in daliy life purposes
@user-hw4qj1rm3o
@user-hw4qj1rm3o Жыл бұрын
How can we ourself initialize the multidimensional array as we do in 1d array
@The_Motobikers_World
@The_Motobikers_World Жыл бұрын
Just simply assigned the value in row and column format where row represent the no of array and column represent the no of elements in the array . Just for example first array 0th element we have to write Array[0][0]=some value; Like wise that second array third element supposed the array size is of 3 Then the syntax will be Array[1][3]=some value;
@The_Motobikers_World
@The_Motobikers_World Жыл бұрын
Another way scanner class should be in a nested loop where outer loop represent the row no(no of array )and inner loop represent the column (no of elements in the array) . The syntax will be:- Arr[row][column]=sc.nextInt();//before that you should include the scanner class in your code and create an object of that .
@user-vx5ig3gf7y
@user-vx5ig3gf7y 7 ай бұрын
broo navin bro thandani thane thane thandane thane thane noo brooo super explanation
@adityakaushik2845
@adityakaushik2845 Жыл бұрын
Math.random not working in my compiler.why??
@nikilkandula8562
@nikilkandula8562 Жыл бұрын
First u have to import it's library
@AravStark
@AravStark Жыл бұрын
You have to import it bro
@lohithareddy15
@lohithareddy15 Жыл бұрын
@@nikilkandula8562 how can i import math library in vs codde.....can u please help me
@ArjunU931
@ArjunU931 Жыл бұрын
​​@@lohithareddy15 type this code in the first line ok. " import java.lang.Math; ". 😊
@cosmesumagaysay7126
@cosmesumagaysay7126 3 ай бұрын
​@@lohithareddy15import java.util.Random;
@shaikbasha3882
@shaikbasha3882 Жыл бұрын
if you are here then i would have kissed on your head man, you just clarified all the doubts which was there from ages ..
@nikilkandula8562
@nikilkandula8562 Жыл бұрын
Sir can we scanner class to intialise variables
@The_Motobikers_World
@The_Motobikers_World Жыл бұрын
Yes, scanner class should be in a nested loop where outer loop represent the row no(no of array )and inner loop represent the column (no of elements in the array) . The syntax will be:- Arr[row][column]=sc.nextInt();//before that you should include the scanner class in your code and create an object of that .
@YoutubeCom-de9ye
@YoutubeCom-de9ye Жыл бұрын
Sir pls give free coupon code for your Udemy course. It's an amazing course and your explanation it just excellent
@mrgold8267
@mrgold8267 Жыл бұрын
Why don't we do this: Random rand = new Random(); import java.util.Random; class Main { public static void main(String[] args) { Random rand = new Random(); int[][] arr = new int[5][]; for(int i = 0; i < arr.length; ++i) { arr[i] = new int[rand.nextInt(5,10)]; for (int j = 0; j < arr[i].length; ++j) { arr[i][j] = rand.nextInt(0,10); } } for(int i = 0; i < arr.length; ++i) { for (int j = 0; j < arr[i].length; ++j) { System.out.print(arr[i][j] + " "); } System.out.println(); } } }
@CHALLENGESTORY
@CHALLENGESTORY 8 ай бұрын
😂
@AravStark
@AravStark Жыл бұрын
I had a doubt, while typing it in the comments, it was solved 🤣🤣🤣
@kvelez
@kvelez 9 ай бұрын
import java.util.Arrays; public class Main{ public static void main(String[] args) { int[][] nums = new int[3][4]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 4; j++) { int random = (int)(Math.random() * 10);//type casting nums[i][j] = random; System.out.print(random + " ");//row limit } System.out.println();//line break } System.out.println();//For each format for (int[] num : nums) { System.out.println(Arrays.toString(num)); } System.out.println();//For each format for (int[] is : nums) { for (int is2 : is) { System.out.print(is2 + " "); } System.out.println(); } } }
@sindhunayak9354
@sindhunayak9354 28 күн бұрын
Who don't have laptop or desktop And practice with mobile
@rohitpal73
@rohitpal73 7 күн бұрын
Lol 😂😂😂😂
#30 jagged and 3D Array in Java
5:38
Telusko
Рет қаралды 99 М.
Real reason behind Microsofts blue screen of Death
9:28
Hitesh Choudhary
Рет қаралды 110 М.
THEY made a RAINBOW M&M 🤩😳 LeoNata family #shorts
00:49
LeoNata Family
Рет қаралды 42 МЛН
Русалка
01:00
История одного вокалиста
Рет қаралды 7 МЛН
HAPPY BIRTHDAY @mozabrick 🎉 #cat #funny
00:36
SOFIADELMONSTRO
Рет қаралды 17 МЛН
071024 COSC 1336 Python object-oriented: Account class deposit
8:57
#28 Creation of Array in Java
7:29
Telusko
Рет қаралды 132 М.
#26 Stack And Heap in Java
12:37
Telusko
Рет қаралды 213 М.
2D Array Java Tutorial #11
8:34
Alex Lee
Рет қаралды 339 М.
Dictionary in Python
12:24
Telusko
Рет қаралды 1,3 МЛН
#32 Array of Objects in Java
8:52
Telusko
Рет қаралды 120 М.
2D Arrays in Java
14:57
Simply Coding
Рет қаралды 23 М.
Array vs. ArrayList in Java Tutorial - What's The Difference?
17:36
Coding with John
Рет қаралды 506 М.
Копия iPhone с WildBerries
1:00
Wylsacom
Рет қаралды 2,4 МЛН
Что не так с раскладушками? #samsung #fold
0:42
Не шарю!
Рет қаралды 215 М.
S24 Ultra and IPhone 14 Pro Max telephoto shooting comparison #shorts
0:15
Photographer Army
Рет қаралды 9 МЛН
Rate This Smartphone Cooler Set-up ⭐
0:10
Shakeuptech
Рет қаралды 1,1 МЛН