Nested For Loop In Java Tutorial #24

Поділитися
Вставка
  • Опубліковано 5 січ 2025

КОМЕНТАРІ • 230

  • @alexlorenlee
    @alexlorenlee  Рік тому +5

    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 4 роки тому +122

    I didn't pay attention in my java class and now this guy saved my life

  • @PeanutButter2024
    @PeanutButter2024 4 роки тому +94

    This guy the GOAT, best tutorials I've seen

  • @aquarocket8165
    @aquarocket8165 4 роки тому +23

    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 роки тому +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 роки тому +17

    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!

  • @zxrfp
    @zxrfp 5 років тому +17

    I had no idea what we were doing in class today, thanks for the help!

  • @nicklund304
    @nicklund304 10 місяців тому

    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!

  • @berror2994
    @berror2994 6 днів тому

    I finally understand how Nested For Loop works! Thank You!!!

  • @phanta5m
    @phanta5m 4 роки тому +1

    Good thing i ran to your videos while learning java , the old concept i learned in cpllege are now cleaner, good job Alex.

  • @rittenbrake1613
    @rittenbrake1613 4 роки тому +2

    hey I think u teach better than others , esp in explaining the nested loops topic , listing all i and j

  • @echiwav
    @echiwav Рік тому

    dude i have an exam on nested loops in like 1 hour and you just saved my ass thank you so much

  • @dokadoki6514
    @dokadoki6514 4 роки тому +20

    Ah im telling you im gonna fall in love with this guy HAHA
    What a life saver hahaahsha thanks man!

  • @arthurivex2298
    @arthurivex2298 4 роки тому +1

    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!

  • @Cablur
    @Cablur 4 роки тому +5

    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! 🥰

  • @davianbrown6058
    @davianbrown6058 4 роки тому +1

    Best java tutorials on youtube!!

  • @fredericoamigo
    @fredericoamigo 3 роки тому +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!

  • @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.

  • @heineken9329
    @heineken9329 5 років тому +34

    Thanks for explaining clearly, this nested is so hard for me at starting 2 months at coding. Nested and array are so difficult.

  • @shadmanahmed271
    @shadmanahmed271 4 роки тому +3

    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

  • @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 !!

  • @general_pepito
    @general_pepito 4 роки тому +1

    Good job man one of the best tutorials I've seen

  • @chandureddy5208
    @chandureddy5208 4 роки тому

    Completed Playlist- Java Basics 2 Good videos thanks Alex!

  • @aishwarya6123
    @aishwarya6123 4 роки тому +1

    I absolutely LOVE these! Easy to understand, to the point and helpful. Thanks a lot, Lee!

  • @serdargayibov8190
    @serdargayibov8190 3 роки тому +1

    Thank you so much! It breaks down simple concepts for easier understanding

  • @Slyferrr
    @Slyferrr 2 роки тому +1

    Wow you deserve so much more views and subs !

  • @aaronwhite1426
    @aaronwhite1426 2 роки тому

    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!

  • @vitocorleone6040
    @vitocorleone6040 4 роки тому +2

    Making for loops to find perfect numbers from 1-10000 First intro programming class this shit helped a lot

  • @vishaalguru9666
    @vishaalguru9666 5 років тому +9

    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

  • @jadenhuynh5026
    @jadenhuynh5026 4 роки тому

    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!

  • @nersiyangassan9130
    @nersiyangassan9130 4 роки тому +1

    you made it so much easier to me to understand and i hope to pass my test with a great mark😩❤️

  • @mingchen6229
    @mingchen6229 5 років тому +19

    It's good, easy to understand. Thanks!

    • @alexlorenlee
      @alexlorenlee  5 років тому +4

      Ming Chen I’m happy it helped you!

  • @FederikoKorili
    @FederikoKorili Рік тому

    Dziękujemy za zrobienie tego i innych samouczków java!

  • @kentspencermedez5607
    @kentspencermedez5607 2 роки тому

    thank youuu!!!! 🙇🏻‍♂️ now it's clear to me how nested for loops are for 2D arrays 😁 thanks a lot!!!! 🖤🖤🖤

  • @IrrelevantOracle
    @IrrelevantOracle 2 роки тому

    Seeing this video for learning purpose. I appreciate your efforts. Keep it UP!!

  • @Drdominguezc
    @Drdominguezc 2 роки тому

    After watch so many videos, thanks to this one i finally understand it... 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!

  • @ghostsalify2796
    @ghostsalify2796 4 роки тому +2

    Hey Alex, you're making it a bit too easy.
    AND I LIKE IT!!!

  • @kkustos
    @kkustos 5 років тому +1

    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 2 роки тому

      @@sabrinakomm750 there are many... //when you play scrabble too much...lol

  • @coolboy.bladersshow9159
    @coolboy.bladersshow9159 4 роки тому

    Thanks bro!!!! I had a lot of confusion but you helped me understand it easily.

  • @kami6031
    @kami6031 4 роки тому +29

    just want this dude to know I’m passing ap comp sci because of him

    • @KR-vu9mo
      @KR-vu9mo 4 роки тому +3

      Me too I’ve been winging it for weeks now with no idea how to use for loops thank god for Alex lol

  • @batool3dnan
    @batool3dnan 5 років тому +3

    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!

  • @leoulfitness
    @leoulfitness 3 роки тому

    Thank you so much for your help! I was using this video to learn how to loop through 2D Arrays.

  • @OSAMA-xn1zm
    @OSAMA-xn1zm 4 роки тому +5

    I can’t say thanks enough ❤️❤️

  • @Kav2990
    @Kav2990 9 місяців тому +1

    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

  • @BeastReview
    @BeastReview 5 років тому +7

    I had to check the date on the video when I saw the keyboard he is using

  • @kaleido6096
    @kaleido6096 3 роки тому +1

    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!!

  • @talhasiddique2376
    @talhasiddique2376 5 років тому

    Your videos are so helpful I learnt oop following your video. Thanks a lot !

  • @trex_7
    @trex_7 4 роки тому

    simple tutorial ezzzz java , thanx man

  • @VirtualVisionStudiosOfficial
    @VirtualVisionStudiosOfficial 5 років тому +3

    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.

  • @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.

  • @youkeshgurung5280
    @youkeshgurung5280 4 роки тому +1

    Thank you so much. You are really a awesome teacher.

  • @bran-chex7798
    @bran-chex7798 Рік тому

    Best video opening ever!

  • @blackTulpan
    @blackTulpan 2 роки тому

    Thank you Alex! Cool video
    and cool music!!!

  • @trevador_2002
    @trevador_2002 5 років тому +1

    Thanks man I’m in a AP CSA class and you’re clarifying how this works for me and helping me understand better

  • @MrConsciousness
    @MrConsciousness 2 роки тому +1

    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

  • @ericakay6715
    @ericakay6715 5 років тому +2

    Thank you for sharing your knowledge!You are the best!

  • @ZianBhutta
    @ZianBhutta 4 роки тому

    Got a nested loops quiz tomorrow and this video is teaching me for it 😂

  • @iamsimran2402
    @iamsimran2402 3 роки тому

    it helped me with my assignment thanku

  • @xdavier31
    @xdavier31 5 років тому

    @ 9:00
    Wouldn't it run 36 times since they're(i & j) less than(

    • @alexlorenlee
      @alexlorenlee  5 років тому +1

      _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

  • @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

  • @parthsarthi360
    @parthsarthi360 2 роки тому

    I just like how you use real world examples out there present in the world .... That clears concepts better

  • @connimii9086
    @connimii9086 4 роки тому

    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.

  • @CaitlinB0000
    @CaitlinB0000 4 роки тому +3

    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.

  • @Don-ts8tp
    @Don-ts8tp 5 років тому +2

    Thank you for the help! Amazing content!

  • @jacobwestergren8958
    @jacobwestergren8958 5 років тому

    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].

  • @prithvimarwadi345
    @prithvimarwadi345 5 років тому +5

    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!!

  • @anaraydamir
    @anaraydamir 2 роки тому

    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

  • @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!

  • @slithivi8763
    @slithivi8763 3 роки тому

    How would you make a nested for loop for a 2D Array if you do not know the row and column length?

  • @bubble4770
    @bubble4770 6 років тому +5

    Alex please make a video on pattern program with nested for loops

    • @shavar67
      @shavar67 5 років тому

      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

  • @WOLF91
    @WOLF91 5 років тому +4

    Thanks man, do you have a video on sorting, searching, and recursion

    • @alexlorenlee
      @alexlorenlee  5 років тому +2

      Jairo Poveda not yet, but I probably will in the future

  • @Mnuller
    @Mnuller 2 роки тому

    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

  • @Backflipmarine
    @Backflipmarine 4 роки тому

    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.

  • @spidey-yz1vc
    @spidey-yz1vc 9 місяців тому

    you are A legend

  • @christopherapuan9968
    @christopherapuan9968 2 роки тому

    I am learning this in my programming I class.

  • @andreacorrales7388
    @andreacorrales7388 3 роки тому

    this is fantastic thank you alex

  • @dreamwasdenied1782
    @dreamwasdenied1782 3 роки тому

    it was really really good thanx so much :D . that made my day

  • @FriedRice3519
    @FriedRice3519 5 років тому +1

    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

  • @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 !

  • @kakashi99908
    @kakashi99908 2 роки тому

    I think it is much easier to explain this using regular array syntax instead of the curly braces shortcut

  • @khadijasyed3433
    @khadijasyed3433 3 роки тому

    plz show how to save it and where will be that save code

  • @ashvinirewatkar5507
    @ashvinirewatkar5507 4 роки тому

    Thanks Alex

  • @cactusdg
    @cactusdg 3 роки тому

    Thank you ,Alex!

  • @gavcx
    @gavcx Рік тому

    I LOVE YOU ALEX !!!!

  • @kitchentable8529
    @kitchentable8529 6 років тому +2

    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  6 років тому

      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 6 років тому +1

      @@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  6 років тому

      Kitchen Table yea! Send it to my email alexlorenlee@gmail.com and I’ll get your code working

  • @kcconsigo7429
    @kcconsigo7429 4 роки тому

    To understand more regarding these loops 😁

  • @edouardwilliam2883
    @edouardwilliam2883 3 роки тому

    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

  • @shaikrazik8926
    @shaikrazik8926 3 роки тому

    What soft application to run the program please tell me anyone .my laptop windows 10

  • @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?

  • @MrChevux
    @MrChevux 3 роки тому +2

    Hey Alex,
    first of all, your tutorials are great! One question, do you recommend any books for java programming?
    Thanks in advance :)
    Best regards

  • @mahfozaabdelhai3010
    @mahfozaabdelhai3010 Рік тому

    Literally your the best 🙏

  • @thelilpippin
    @thelilpippin 4 роки тому

    Holy shit it's making sense

  • @zanettd1037
    @zanettd1037 3 роки тому

    I just want to say: MARYY MEEEEEEE
    no but seriously, thank you so much. you teach java very efficiently

  • @nerodant85
    @nerodant85 5 років тому +2

    Thanks Alex!

  • @TravelNewZealand_WithAfza
    @TravelNewZealand_WithAfza 9 місяців тому +1

    best i like it

  • @jasonhusser8743
    @jasonhusser8743 4 роки тому

    Where did you get your keyboard?

  • @abscodes9587
    @abscodes9587 3 роки тому

    turquoise lol. you are a star Alex

  • @Thegr8aarod
    @Thegr8aarod 5 років тому +1

    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?

  • @mehrabhasantanim338
    @mehrabhasantanim338 4 роки тому

    what
    copy and pest !
    that the right way you think to learn?

  • @chonylau6981
    @chonylau6981 4 роки тому +1

    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 роки тому +1

      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.