No video

Nested For Loop In Java Tutorial #24

  Рет қаралды 267,958

Alex Lee

Alex Lee

Күн бұрын

$1,000 OFF ANY Springboard Tech Bootcamps with my code ALEXLEE. See if you qualify for the JOB GUARANTEE! 👉 bit.ly/3HX970h
The nested for loop in java is just a for loop inside of a for loop. A common way to use a nested for loop in java is to get elements from a 2d array. To do that, your outer for loops takes care of the rows and your inner for loop takes care of the columns.
Java loops can be VERY tricky, but don't worry too much about it right now! Use the code I provided and after time you'll get the hang of java loops :) If you followed along, congrats! You learned-by-doing!
I hope you enjoyed this nested for loop in java tutorial! I like to have a nice mix of tutorials and actual projects for you all :)
🌅 Source Code - github.com/ale...
Do you want to learn how to code from scratch, in Java? Check out my Java Tutorial For Beginners: • Coding For Beginners I...
How are you using nested for loops in java? -
Full Java Tutorial For Beginners Playlist: • Full Java Course by Al...
Free Tips: bit.ly/3U6HXcb
Disclosure: The Springboard link provided is linked to my affiliate account & supports the channel.
~
Alex Lee

Пікірлер: 227
@alexlorenlee
@alexlorenlee 10 ай бұрын
If you’re new to programming but want a career in tech, I HIGHLY RECOMMEND applying to one of Springboard’s online coding bootcamps (use code ALEXLEE for $1,000 off): bit.ly/3HX970h
@sprutxz
@sprutxz 3 жыл бұрын
I didn't pay attention in my java class and now this guy saved my life
@thecodingchannelph
@thecodingchannelph 3 жыл бұрын
nice
@kevinburns8473
@kevinburns8473 2 жыл бұрын
At least you had a java class, all I have is stupid Pseudo code and a lab.
@thecodingchannelph
@thecodingchannelph 2 жыл бұрын
@@kevinburns8473 nice
@gamingwithronpubgm3615
@gamingwithronpubgm3615 Жыл бұрын
@@kevinburns8473 u shuck
@kevinburns8473
@kevinburns8473 Жыл бұрын
@@gamingwithronpubgm3615 yeah no kidding 😂
@PeanutButter2024
@PeanutButter2024 4 жыл бұрын
This guy the GOAT, best tutorials I've seen
@Reeddollaz14
@Reeddollaz14 3 жыл бұрын
🐐
@aquarocket8165
@aquarocket8165 4 жыл бұрын
If you have an array with different dimmensions try: for(int i =0; i< array.lenght; i++) { for(int j =0; j< array[0].length; j++) { } } This will go through all values in array that is or isnt square
@mohammedibrahim8428
@mohammedibrahim8428 2 жыл бұрын
This is a great tip! Also just in case you have a different number of items in each row, you could improve upon this by checking the length of each row: for (int i = 0; i < array.length; i++) for (int j = 0; j < array[i].length; j++) System.out.println(array[i][j]);
@TheGallyp
@TheGallyp 4 жыл бұрын
Alex, people like me need your videos! Whenever I am confused about anything or need an explanation I can understand I can always count on you. Please never stop making videos!
@zxrif5004
@zxrif5004 4 жыл бұрын
I had no idea what we were doing in class today, thanks for the help!
@thecodingchannelph
@thecodingchannelph 2 жыл бұрын
nice
@dokadoki6514
@dokadoki6514 3 жыл бұрын
Ah im telling you im gonna fall in love with this guy HAHA What a life saver hahaahsha thanks man!
@phanta5m
@phanta5m 3 жыл бұрын
Good thing i ran to your videos while learning java , the old concept i learned in cpllege are now cleaner, good job Alex.
@heineken9329
@heineken9329 4 жыл бұрын
Thanks for explaining clearly, this nested is so hard for me at starting 2 months at coding. Nested and array are so difficult.
@Cablur
@Cablur 4 жыл бұрын
Man, I really was blown away by this amazing tutorial on nested loops! It's sooo damn good! Also I love how easy you explained how to use it to print 2D arrays. Thank you so so much! 🥰
@rittenbrake1613
@rittenbrake1613 4 жыл бұрын
hey I think u teach better than others , esp in explaining the nested loops topic , listing all i and j
@nicklund304
@nicklund304 6 ай бұрын
This videos are incredible! I cannot understand what my Java teacher says for the life of me but this makes so much sense! Thank you!
@davianbrown6058
@davianbrown6058 3 жыл бұрын
Best java tutorials on youtube!!
@fredericoamigo
@fredericoamigo 3 жыл бұрын
Great vid! Super helpful! You are awesome! Since you asked, I'm learning about nested for loops because they're one of the key concepts to get your head around if you want to reach a higher level of programming (in my opinion). Furthermore, I would say that nested for loops and nested while loops open up a lot more possibilities - so thanks a lot for this very explanatory video!
@arthurivex2298
@arthurivex2298 4 жыл бұрын
I'm using it for an assingment, this really gave me the basis of Nested For Loops. I'm using to create the infamous create words out of phone numbers ie: 2 = ABC, so there is about 2143 different combinations for a 7 digit phone number, and I'm going to use for loops to help with this, I hope. Almost forgot the 2D arrays video also helped in using [ ][ ]{"A", "B", "C"},{"D ", "E ", "F "}, etc. Thank you again!
@vishaalguru9666
@vishaalguru9666 4 жыл бұрын
Myself in APCSA class, first time student come from India to US of A, my first teacher Sridhar Kandukari very smart man, he help me now u teach me, very nice sir, vineeth kandukuri also likes ur teachigg always watches video with fav lemon pickle recipe from vah chef
@thecodingchannelph
@thecodingchannelph 3 жыл бұрын
nice
@vitocorleone6040
@vitocorleone6040 3 жыл бұрын
Making for loops to find perfect numbers from 1-10000 First intro programming class this shit helped a lot
@mingchen6229
@mingchen6229 5 жыл бұрын
It's good, easy to understand. Thanks!
@alexlorenlee
@alexlorenlee 5 жыл бұрын
Ming Chen I’m happy it helped you!
@general_pepito
@general_pepito 3 жыл бұрын
Good job man one of the best tutorials I've seen
@sayed.ahmadmosavi1517
@sayed.ahmadmosavi1517 4 жыл бұрын
i recently start learning java online to get a job, i do have teacher to teach me but i never understand what he is saying till , but the good things i found your videos on youTube and your way to teach is amazing, you are amazing.
@vesakonjufca3077
@vesakonjufca3077 5 ай бұрын
are you a programmer now?
@kkustos
@kkustos 5 жыл бұрын
Turquoise* All secondary colors of light are combinations of the primary colors: Red, Green and Blue. However, the third secondary color of light is Yellow. That's what you get when you combine Green and Red. Color and spelling aside, thank you for taking the time to create these videos and for launching your own coding community. I joined the Discord and found the links there very helpful.
@alexlorenlee
@alexlorenlee 5 жыл бұрын
Kustos that’s great thank you!
@sabrinakomm750
@sabrinakomm750 5 жыл бұрын
@@alexlorenlee just remember there's no word in the english language, where the letter U doesnt follow Q ;) (ie: queen, quack, etc.)
@thelolfrog
@thelolfrog Жыл бұрын
@@sabrinakomm750 there are many... //when you play scrabble too much...lol
@lake1495
@lake1495 Жыл бұрын
This guy is literally teaching me Java more the paid courses very good explaining and makes everything simple a lot of people owe this guy honestly !!
@serdargayibov8190
@serdargayibov8190 3 жыл бұрын
Thank you so much! It breaks down simple concepts for easier understanding
@aishwarya6123
@aishwarya6123 3 жыл бұрын
I absolutely LOVE these! Easy to understand, to the point and helpful. Thanks a lot, Lee!
@kami6031
@kami6031 3 жыл бұрын
just want this dude to know I’m passing ap comp sci because of him
@KR-vu9mo
@KR-vu9mo 3 жыл бұрын
Me too I’ve been winging it for weeks now with no idea how to use for loops thank god for Alex lol
@echiwav
@echiwav Жыл бұрын
dude i have an exam on nested loops in like 1 hour and you just saved my ass thank you so much
@shadmanahmed271
@shadmanahmed271 4 жыл бұрын
Your teaching style is literally very good your videos deserve to be viral in india i tried my best to share your teaching 😊 Little suggestions: take ur course to udemy
@FederikoKorili
@FederikoKorili 11 ай бұрын
Dziękujemy za zrobienie tego i innych samouczków java!
@VirtualVisionStudiosOfficial
@VirtualVisionStudiosOfficial 5 жыл бұрын
Thanks for this video! I understand for loops so much better and when I go through an array. Studying for a test and didn't quite understand this portion.
@alexlorenlee
@alexlorenlee 5 жыл бұрын
Eternity Studios great!
@nersiyangassan9130
@nersiyangassan9130 3 жыл бұрын
you made it so much easier to me to understand and i hope to pass my test with a great mark😩❤️
@jadenhuynh5026
@jadenhuynh5026 3 жыл бұрын
This is my first time watching one of your videos, but I have a feeling that I am gonna watch a lot more this year!
@chandureddy5208
@chandureddy5208 4 жыл бұрын
Completed Playlist- Java Basics 2 Good videos thanks Alex!
@ghostsalify2796
@ghostsalify2796 4 жыл бұрын
Hey Alex, you're making it a bit too easy. AND I LIKE IT!!!
@OSAMA-xn1zm
@OSAMA-xn1zm 3 жыл бұрын
I can’t say thanks enough ❤️❤️
@BeastReview
@BeastReview 4 жыл бұрын
I had to check the date on the video when I saw the keyboard he is using
@aaronwhite1426
@aaronwhite1426 Жыл бұрын
I'm using nested for loops for a class assignment. We are given a number of rows and columns. Rows are integers and columns are alphabetical. so the output should list something like this //row1 1A 1B 1C //row2 2A 2B 2C and so on. Pretty difficult for an online class but your videos help a lot. Thanks!
@trevador_2002
@trevador_2002 5 жыл бұрын
Thanks man I’m in a AP CSA class and you’re clarifying how this works for me and helping me understand better
@kentspencermedez5607
@kentspencermedez5607 2 жыл бұрын
thank youuu!!!! 🙇🏻‍♂️ now it's clear to me how nested for loops are for 2D arrays 😁 thanks a lot!!!! 🖤🖤🖤
@Drdominguezc
@Drdominguezc Жыл бұрын
After watch so many videos, thanks to this one i finally understand it... Thank you!!!
@enesbasaran821
@enesbasaran821 Жыл бұрын
I'm currently studying at a bootcamp to be a QA Engineer, and we have been learning these during Java Classes. I watch your videos to recap, and It's SUPER beneficial
@leoulfitness
@leoulfitness 2 жыл бұрын
Thank you so much for your help! I was using this video to learn how to loop through 2D Arrays.
@batool3dnan
@batool3dnan 5 жыл бұрын
this is very helpful! so happy that i found your channel:)
@alexlorenlee
@alexlorenlee 5 жыл бұрын
BATOOL xx I’m glad you found my channel too! Thank you!
@mukulsharma5738
@mukulsharma5738 4 жыл бұрын
If you do : " System.out.println(ArrayName[i].length); ' before nested loop, It print's out ..I think the Address of the row before printing it's entries !! Which was very helpfu to me, for understanding what it was actually doing!
@IrrelevantOracle
@IrrelevantOracle 2 жыл бұрын
Seeing this video for learning purpose. I appreciate your efforts. Keep it UP!!
@coolboy.bladersshow9159
@coolboy.bladersshow9159 3 жыл бұрын
Thanks bro!!!! I had a lot of confusion but you helped me understand it easily.
@youkeshgurung5280
@youkeshgurung5280 4 жыл бұрын
Thank you so much. You are really a awesome teacher.
@alexlorenlee
@alexlorenlee 4 жыл бұрын
thank you!!
@jawadalomari6397
@jawadalomari6397 2 жыл бұрын
when I get a problem in a code, all I need is to check your channel. thank you
@trex_7
@trex_7 3 жыл бұрын
simple tutorial ezzzz java , thanx man
@ericakay6715
@ericakay6715 4 жыл бұрын
Thank you for sharing your knowledge!You are the best!
@prithvimarwadi345
@prithvimarwadi345 4 жыл бұрын
can you make one more video on Multi-Dimensional Arrays, to be more specific on " HOW TO VISUALIZE A TABLE MADE using 2d Arrays" ; it will be such a relief if i get my doubts clear on that topic please!!
@saikarthikmannava4045
@saikarthikmannava4045 5 жыл бұрын
Thank you Alex!, watched so many videos but only understood after your video. It was a great help. Please make videos on Sorting and Searching Algorithms in java. Waiting for those videos.
@Slyferrr
@Slyferrr 2 жыл бұрын
Wow you deserve so much more views and subs !
@CaitlinB0000
@CaitlinB0000 4 жыл бұрын
QOTD... I’m using nested inside nested loops to run a simple word game for kids. I’m still wrapping my head around what I want to accomplish and the logic behind putting together the code to make it happen.
@bran-chex7798
@bran-chex7798 10 ай бұрын
Best video opening ever!
@talhasiddique2376
@talhasiddique2376 4 жыл бұрын
Your videos are so helpful I learnt oop following your video. Thanks a lot !
@ZianBhutta
@ZianBhutta 4 жыл бұрын
Got a nested loops quiz tomorrow and this video is teaching me for it 😂
@bubble4770
@bubble4770 5 жыл бұрын
Alex please make a video on pattern program with nested for loops
@shavar67
@shavar67 4 жыл бұрын
bubble channel for(int i = 0; i < 7;i++){ for(int j = 0; j < i;j++){ System.out.print("*"); } System.out.println(); } Output: * ** *** **** ***** ****** Explanation: outer loops executes until the condition is met(i = 7), The inner loop executes while j is less than i When i = 0 J = 0 Increment i to 1 Now the second time through the loop I = 1 j = 0 0 is less than one so print an * , increment j to 1 and check the condition again 1 isn’t less than 1 so we exit that loop and print an empty space, Now i = 2 J = 0 0 is less than 2 so we print * I is still 2 But now we increment j J = 1 1 is less than 2 so we print another * So far the sequence is * ** J is now incremented to 2 Now we check to see if j < i (2
@iamsimran2402
@iamsimran2402 2 жыл бұрын
it helped me with my assignment thanku
@Don-ts8tp
@Don-ts8tp 4 жыл бұрын
Thank you for the help! Amazing content!
@cubrain2413
@cubrain2413 2 жыл бұрын
I use 'nested for loops' for number patterns in school. If you make a video on it, it'll be pretty cool! Thanks for the great tutorials!
@blackTulpan
@blackTulpan 2 жыл бұрын
Thank you Alex! Cool video and cool music!!!
@kaleido6096
@kaleido6096 3 жыл бұрын
Alex you must be an angel in disguise... Thank you thank you thank you soooo much because I thought that I’d never understand this! I’m really happy right now!!
@thecodingchannelph
@thecodingchannelph 3 жыл бұрын
nice
@parthsarthi360
@parthsarthi360 Жыл бұрын
I just like how you use real world examples out there present in the world .... That clears concepts better
@anaraydamir
@anaraydamir Жыл бұрын
everything is great .Thank you Alex! I think Length method would be more easier because sometimes we can have a lot of rows and column
@MrChevux
@MrChevux 3 жыл бұрын
Hey Alex, first of all, your tutorials are great! One question, do you recommend any books for java programming? Thanks in advance :) Best regards
@thecodingchannelph
@thecodingchannelph 2 жыл бұрын
Java How to Program; Deitel & Deitel
@connimii9086
@connimii9086 3 жыл бұрын
First thing's first cool video and thanks for the help. We had to use nested for loops to create scenes like 1 12 123 1234 12345 123456 and so on and so forth. I guess this is pretty basic but I also practiced 2d arrays with it.
@jacobwestergren8958
@jacobwestergren8958 4 жыл бұрын
quick question, what is the benefit of doing a 2d array instead of just making a longer normal array? For example, { red, blue, green} {yellow, orange, red} can just be {red, blue, green, yellow, orange, red} and when you want to get an element you can just say colour[2] instead of colour[0] [2].
@FriedRice3519
@FriedRice3519 4 жыл бұрын
Next time can you please do a video on nested for loop example questions and go through them? It will be very helpful since I've been having trouble in computer science class
@WOLF91
@WOLF91 5 жыл бұрын
Thanks man, do you have a video on sorting, searching, and recursion
@alexlorenlee
@alexlorenlee 5 жыл бұрын
Jairo Poveda not yet, but I probably will in the future
@gregoryweb3
@gregoryweb3 3 жыл бұрын
Thank you lex for the video you shared I learned a lot with your videos especially we are creating chatbot I used some of codes from you
@spidey-yz1vc
@spidey-yz1vc 4 ай бұрын
you are A legend
@nerodant85
@nerodant85 4 жыл бұрын
Thanks Alex!
@iconiccalico1875
@iconiccalico1875 4 жыл бұрын
turquoise :)
@akizaizayoi4763
@akizaizayoi4763 5 жыл бұрын
Thanks man. Studying these in advance because my prof is really a terror. Sure, he teaches well. But I feel so scared of him and he makes us do live coding in front(he's a very traditional prof). I'm a slow learner too so I might as well self study via KZfaq, Google or any sources outside of school in advance.
@alexlorenlee
@alexlorenlee 5 жыл бұрын
Artillerist X Duelist great idea, that’s exactly what I went through too :/
@chonylau6981
@chonylau6981 4 жыл бұрын
Hi Alex, I like your videos a lot. I'm having a class presentation coming soon, and would like to ask you what recording software you are using? Your videos are all crystal clear and the layout is also nice. Thank you in advance.
@SkyeVintorez
@SkyeVintorez 4 жыл бұрын
Any vid software will work, you need to,set it in 720p and up for better resolution and quality,,but it takes a lot of File size
@chonylau6981
@chonylau6981 4 жыл бұрын
@@SkyeVintorez Thanks Jefferson, I end up going with OBS.
@ashvinirewatkar5507
@ashvinirewatkar5507 4 жыл бұрын
Thanks Alex
@andreacorrales7388
@andreacorrales7388 3 жыл бұрын
this is fantastic thank you alex
@Mnuller
@Mnuller Жыл бұрын
Hey Alex :) In your 2d array - you write for (int i = 0; i < 2 ; i++) - why dont it go out of bounds, seeing that there are only 2 rows? 0 and 1
@Kav2990
@Kav2990 5 ай бұрын
I know it's a 5 year old video, but for anyone watching now, it's spelled "Turquoise", and if you use intellij, it has an autocorrect feature
@gregd4354
@gregd4354 2 жыл бұрын
Thank you ,Alex!
@thelilpippin
@thelilpippin 3 жыл бұрын
Holy shit it's making sense
@himnishdhiman1370
@himnishdhiman1370 3 жыл бұрын
Alex , I think these nested loops can also be used for a 3d array LiKE This :- public class NestedForLoops { public static void main(String[] args) { String[][][] Array = {{{"Hi" , "Hello" , "Hey"},{"Bye" , "BabBye" , "Bye-Bye"}}}; for(int i = 0 ; i < 2 ; i++) { for(int j = 0 ; j < 3 ; j++) { for(int k = 0 ; k < 3 ; k++) { System.out.println(Array[i][j][k]); } } } } }
@christopherapuan9968
@christopherapuan9968 2 жыл бұрын
I am learning this in my programming I class.
@edouardwilliam2883
@edouardwilliam2883 2 жыл бұрын
Very helpful sir.....Sir can you do one where you have to calculate the average of 3 numbers using nested for loop using java coding
@berceanuflorin9012
@berceanuflorin9012 3 жыл бұрын
Hello Alex ! I can't understand this part: String[][] fancyColors = { { "Red", "Blue", "Green" }, { "Cyan", "Magenta", "Turqiouse" } }; for (int row = 0; row < 2; row++) { for (int column = 0; column < 3; column++) { System.out.println(fancyColors[row][column]); } } Can you explain to me please why in the second loop is "column < 3" and in the forst loop it is "row < 2" ? Because in the both arrays we have 3 elements. Thanks in advance !
@mustafa-pt3sy
@mustafa-pt3sy 5 жыл бұрын
love you man
@dreamwasdenied1782
@dreamwasdenied1782 3 жыл бұрын
it was really really good thanx so much :D . that made my day
@gavcx
@gavcx 10 ай бұрын
I LOVE YOU ALEX !!!!
@liangkaijie
@liangkaijie 3 жыл бұрын
Thanks for the tutorials but the music bg is too loudddd..! :))
@abscodes9587
@abscodes9587 2 жыл бұрын
turquoise lol. you are a star Alex
@kcconsigo7429
@kcconsigo7429 4 жыл бұрын
To understand more regarding these loops 😁
@Backflipmarine
@Backflipmarine 3 жыл бұрын
Anyone just starting this, I found that the best way to organize my code within one file is to create a new method for each video, that way I can scroll down for easy review.
@kakashi99908
@kakashi99908 2 жыл бұрын
I think it is much easier to explain this using regular array syntax instead of the curly braces shortcut
@kitchentable8529
@kitchentable8529 5 жыл бұрын
Hey man, can you make a video on do-while loops? I'm working on a project for sh**s and giggles and cont seem to get the loop to work properly.
@alexlorenlee
@alexlorenlee 5 жыл бұрын
Kitchen Table sure! I have videos planned for a few weeks, but I’ll do while loops after that. I can help you now, and I’ll see if I can give you some advice
@kitchentable8529
@kitchentable8529 5 жыл бұрын
@@alexlorenlee that would be awesome. I'm basically working on a "guess the number" game for practice, that all runs in a do/while loop. is there some way I can send you the code or something?
@alexlorenlee
@alexlorenlee 5 жыл бұрын
Kitchen Table yea! Send it to my email alexlorenlee@gmail.com and I’ll get your code working
@xdavier31
@xdavier31 4 жыл бұрын
@ 9:00 Wouldn't it run 36 times since they're(i & j) less than(
@alexlorenlee
@alexlorenlee 4 жыл бұрын
_BlueBlazing_ great question! At first glance it looks like it would, but since we set i to 0, it includes 0, totaling to 5 and 10
@Thegr8aarod
@Thegr8aarod 4 жыл бұрын
Is there a order of learning these different types of code, like learn for loops first then do loops, etc? If so then which of your videos should I start with first?
@thecodingchannelph
@thecodingchannelph 3 жыл бұрын
for loops, while then do while
@mahfozaabdelhai3010
@mahfozaabdelhai3010 Жыл бұрын
Literally your the best 🙏
@bigshot_07
@bigshot_07 4 жыл бұрын
Im using nested for loops for making triangular hash pyramid 👀 @alex lee
@springbahor
@springbahor 2 жыл бұрын
Thank you Alex
@dinhomhm
@dinhomhm 4 жыл бұрын
Thank you and it is very clear, I just have a question, what if the rows and columns elements were not the same length, when I try it, I get errors with missing output, so how to print it all with no errors?
For Loop Pattern Program In Java #25
15:49
Alex Lee
Рет қаралды 167 М.
While Loop Java Tutorial #37
8:51
Alex Lee
Рет қаралды 310 М.
managed to catch #tiktok
00:16
Анастасия Тарасова
Рет қаралды 48 МЛН
I Took a LUNCHBAR OFF A Poster 🤯 #shorts
00:17
Wian
Рет қаралды 8 МЛН
Gli occhiali da sole non mi hanno coperto! 😎
00:13
Senza Limiti
Рет қаралды 22 МЛН
SPONGEBOB POWER-UPS IN BRAWL STARS!!!
08:35
Brawl Stars
Рет қаралды 22 МЛН
Nested Loops in Java
10:09
Neso Academy
Рет қаралды 271 М.
Learn Java in 14 Minutes (seriously)
14:00
Alex Lee
Рет қаралды 4,7 МЛН
For Each Loop In Java Tutorial #39
9:08
Alex Lee
Рет қаралды 134 М.
Abstract Class In Java Tutorial #79
8:55
Alex Lee
Рет қаралды 539 М.
If Else Statement In Java Tutorial #17
7:39
Alex Lee
Рет қаралды 323 М.
For Loop Java Tutorial #23
7:54
Alex Lee
Рет қаралды 397 М.
Object-Oriented Programming Java Tutorial (Java OOP) #71
14:07
How to predict human behavior
12:51
Psychology with Dr. Ana
Рет қаралды 8 М.
Inheritance in Java Tutorial #86
10:34
Alex Lee
Рет қаралды 382 М.
managed to catch #tiktok
00:16
Анастасия Тарасова
Рет қаралды 48 МЛН