Array vs. ArrayList in Java Tutorial - What's The Difference?

Поделиться
HTML-код
  • Опубликовано: 10 янв 2025

Комментарии • 561

  • @whatisahandleeee
    @whatisahandleeee 2 года назад +442

    Easily top 3 programming teachers on youtube. No joke. You seem to answer the exact questions that a newbie would asks and you answer in such a way that gives exactly the information that is needed.

    • @ilhammammadli4560
      @ilhammammadli4560 2 года назад +1

      who is rest?

    • @whatisahandleeee
      @whatisahandleeee 2 года назад +5

      @@ilhammammadli4560 Corey Schafer is one of them for sure.

    • @sophie6425
      @sophie6425 2 года назад +4

      Agreed! I´m a first semester Computer Science student and we must do these little coding exercises. The lectures don´t really help, but these videos really got me through these tasks.

    • @abflores11
      @abflores11 2 месяца назад

      I wish our professors explain like this, the explanation is so clear

  • @aligmayu5322
    @aligmayu5322 3 года назад +392

    PLEASE DONT STOP TEACHING THIS THINGS.. I HAVE WATCHED A LOT OF GUYS LIKE U ON RUclips AND UR ONE OF THE BEST. AND STILL I LOVE JAVA MORE EVEN AFTER MEETING PYTHON

    • @trynafindkaygee_
      @trynafindkaygee_ 3 года назад +2

      i can relate to that❤😎👌

    • @spacepowerofficial1187
      @spacepowerofficial1187 2 года назад +6

      I didn't see the DONT and I got really confused

    • @butterandjamtoast
      @butterandjamtoast 2 года назад +4

      Caps Lock. The cruise control to cool 😎

    • @ArsArs-x7i
      @ArsArs-x7i Год назад

      Axper angleren chem xosum ches kara bacatres incha patmum?

    • @darrenfrancis8126
      @darrenfrancis8126 Год назад +3

      @@spacepowerofficial1187 PLEASE STOP TEACHING
      imagine

  • @kerwinso
    @kerwinso 3 года назад +133

    You explain diamond operators (starting at 4:19) in 20 seconds better than others who have taken over 5 minutes. Well done sir.

  • @mk17173n
    @mk17173n 2 года назад +11

    This dude is the man. His videos are better than others because he answers the question why. Why do we do it this way? Keep it up dude.

  • @anityyu
    @anityyu 2 года назад +6

    I love how my school explains these things in 10 videos and it takes over 5 hours to watch all of them, while I can easily learn it from your video in just 18 min

  • @sanabil2531
    @sanabil2531 3 года назад +270

    you are going to have million subscribers one day, already telling ya, you teach so well :)

    • @wankhede09
      @wankhede09 3 года назад +2

      I Second that

    • @CheeseStickzZ
      @CheeseStickzZ 3 года назад +9

      That's a nice notion but no he wont. Programming is not that popular. Only stupid things are popular, entertainment and food and monkeying around

    • @alicewu6674
      @alicewu6674 2 года назад +3

      I agree... he is great teacher, I love his coding tutorials cuz they are the ones that are among the most understandable and well-explained:)

    • @renathanobre
      @renathanobre 2 года назад

      indeed

    • @MakeItStik
      @MakeItStik 2 года назад

      He is close

  • @lootster
    @lootster Год назад +4

    RUclips algo sucks for not recommending this wonderful video for Java learner! But better late than never!

  • @HuwJones
    @HuwJones 2 года назад +39

    Great video. Two things....it's considered good practice to use the interface on the left side so List instead of ArrayList before the variable name. And while you are right that the ArrayList itself can grow and shrink it's really important to be aware that the array that backs the ArrayList (yes there's an array hiding inside the ArrayList implementation!) does not shrink automatically after the ArrayList has grown...this can be very significant when profiling the memory footprint of an application. Lastly, it would be really good to have a video on why you'd pick a primitive representation over its Object form.....performance, memory usage, etc.

  • @carlosgranda8493
    @carlosgranda8493 3 года назад +1

    Dude, I swear to God how can you explain so well that I didn't get distracted. bro when my teachers explain I lose focus so fast, dude keep it going you are amazing.

  • @beneielohim
    @beneielohim 2 года назад +1

    90% of my Java class success is owed to you. thanks man!

  • @filipemelo1107
    @filipemelo1107 2 года назад +8

    I freaking love the way you approach the subject on your videos... It's so simple and yet, complete; I can understand everything so easily.

  • @alessioharo7995
    @alessioharo7995 2 года назад +2

    You're such a great teacher. Thank you for what you do! I love your videos

  • @footballplayer3195
    @footballplayer3195 Год назад +1

    you are my hero man, I've been using fixed array my whole life, you're best than my professors in college

  • @lunarieu4815
    @lunarieu4815 Год назад +1

    Literally I was crying after my class cause the teacher really did not explain as clear as this video. Honestly, thanks a million!🥰⭐

  • @sarangsambharia2634
    @sarangsambharia2634 Месяц назад

    I believe the best part about your videos is that you make everything sound so simple and easy even if it's not. that makes all the topics you teach less scary. You are gifted. Good Work man.

  • @robertjr8205
    @robertjr8205 9 месяцев назад +1

    Watching your videos helps me understand so much better. You explain everything perfectly and add in the little important details that most books or instructors seem to not mention,
    Thank you!

  • @oldschoolmath8480
    @oldschoolmath8480 3 года назад +23

    Thanks so much for sharing this video! We watched this in my AP CS A course after finishing a unit on Arrays and you did a great job of giving us an intro to ArrayLists.

  • @mastermatt6090
    @mastermatt6090 9 месяцев назад +2

    Thanks dude, you make everything so simple!

  • @shirinelmanson7839
    @shirinelmanson7839 3 года назад +10

    I am literally I am shocked how come you do not have 1 million subscribes ..the way you teach is awsome.

  • @deanflash112
    @deanflash112 10 дней назад

    Hi John, I am currently studying Java with Runestone Academy and using your videos and LeetCode as supplemental guides to improve my understanding of Java. This video was very useful and I appreciate the help! Arrays and array lists are a lot more fun to learn when someone can explain it better than an online textbook.

  • @erickferraz5529
    @erickferraz5529 3 года назад

    Dude, thanks a lot. I’m from Brazil and just had 3 hours of class in my own language and couldn’t get what I got in 17 min in your video. U r a legend.

  • @s6031417
    @s6031417 2 года назад

    This video took me only 17 mins to get fully understand the basic concept of Array and ArrayList.
    Thank you.

  • @thecolorblue7427
    @thecolorblue7427 2 года назад +21

    I was not expecting such a easy to understand, and great tutorial like this! thank you so much

  • @darthvasilis
    @darthvasilis 2 года назад

    Amazing. In 15 minutes I've learned more from you than I have in 10 weeks from my CSC205 professor...

  • @osanbrazil999
    @osanbrazil999 2 года назад

    You're the best because you speak fast and get direct to the point with the exact needed amount of information, period.

  • @abdullahpopalzai6543
    @abdullahpopalzai6543 3 года назад +1

    Please do not stop teaching, you are great!!!!!!

  • @berearobinson6588
    @berearobinson6588 3 месяца назад

    You're the best, sincerely, thank you. The online textbook my university uses is extremely dry and hard to understand. It's always so much better to see someone show how to do something by doing and breaking it down in simple terms. Thank you so much again!

  • @fridolinmeier661
    @fridolinmeier661 2 года назад +1

    Just searched for a good video and wow I could not have found a better one. Thanks a lot.

  • @sajidamoin771
    @sajidamoin771 8 месяцев назад

    You are one of the smartest teachers on youtube… I love your teaching style…Whenever I want to learn a java topic, I first search it on your channel because you explain every topic in a very simple way. Not too much of information not too less… just as much as needed for a beginner… My favorite ❤️

  • @aces8481
    @aces8481 2 года назад +5

    you are 100% my go to person on RUclips for beginner tutorials -> explanations are always really beginner friendly and so clear and easily digestible. Thanks a ton man

  • @barnabastyav3575
    @barnabastyav3575 2 года назад

    this is the best java tutorial i have ever watch , i wish John had a complete series from the basics up, i can beat my chest and say i understand the differences between Arrays and Array list, I recommend it for anyone looking up the internet for answers to arrays and array list

  • @tinongsot6267
    @tinongsot6267 2 года назад +1

    This channel is really underrated, I learned a lot just from this video.
    You’re doing great. Thank you John

  • @Charnelex
    @Charnelex 3 года назад +1

    John, I'm just getting started in Java and I appreciate you. Commenting to help the algorithm.

  • @zachjs2721
    @zachjs2721 7 месяцев назад

    I learn more from you than college professors. You flow through your explanations and it really helps someone like me with adhd lol

  • @smorebytes
    @smorebytes 2 года назад

    I've been out of the Java Ecosystem for years, but I randomly got to your channel I have been enjoying just listening on some of the details of Java again. Great content.

  • @JACINTADOITA
    @JACINTADOITA 4 месяца назад

    My Exam is on Monday and my teacher did not cover this topic on JAVA. By watching this video I'm prepared for my Exam, thanks very much.

  • @tbone587
    @tbone587 3 года назад +1

    I been using java for over a decade and I have still been enjoying your videos! You explain things very well and even these basic concepts are engaging to watch lol

  • @mario_luis_dev
    @mario_luis_dev 2 года назад +5

    The performance difference does add up if you’re using a ton of arrays in your code, or if you’re iterating a lot over the same array(s). With ArraysList Java has to do dynamic allocation behind the scenes, meaning it has to allocate new memory AND copy all the elements from the previous array list whenever you want to resize to a new larger array list. It can definitely slow down your code if you have lots of these lying around or if you’re iterating a lot.

    • @Nallu_Swami
      @Nallu_Swami 2 года назад

      Could you specify out of both of them which were to be faster if used non iteratively many times or even if one of them is to be faster how much of a time difference would it make?

  • @CoolBear619
    @CoolBear619 Год назад

    Thanks much John! Because of you I have cracked 2 interviews. Loads of love from India. Keep teaching us!🎉

  • @ralphrgore
    @ralphrgore 2 года назад +1

    John, I discovered you yesterday and you are one of the best!

  • @thekevinfx-krouxer
    @thekevinfx-krouxer 3 года назад +1

    English is not even my first language but I understood most of the things you said, this is pretty helpful, you will be big one day

  • @bbalmer7878
    @bbalmer7878 Год назад +2

    as I was watching I thought "BUT-BUT you cant DO THAT!" and then you wrote "//you can't do that "
    and i got just a nice ass dopamine hit, thank you.

  • @깃짱
    @깃짱 2 года назад

    Im a student in south korea! Ive been having a hard time learnjng java on my own still im good at python or javascript! I love your java lectures. Thanks a lot!!!!

  • @preciouspearl8583
    @preciouspearl8583 Год назад

    Thumbs up i searched so many tutorials but find yours the straight to the point one

  • @leoMC4384
    @leoMC4384 Год назад +1

    I'm working on an adaptation of 2 REST API I did on Node with MongoDB to Spring Boot with MySQL. But every once in a while it's great go back to the hows and whys of Java. 👏👏👏

  • @IronMeDen1
    @IronMeDen1 Месяц назад

    Hey John! I just wanted to say thank you very much for taking the time to make these videos. I teach Java and I've been using your videos as inspiration (and repetition for myself when needed) because you provide such clear and concise explanations to so many concept. So... THANKS!

  • @stingray-q5p
    @stingray-q5p 2 года назад

    You cannot believe how much my future is dependent on you. Keep at it John. Your work is amazing man. God bless

  • @jorgegutierrez2100
    @jorgegutierrez2100 3 года назад +9

    Quality content, great at teaching, quality video and the most important for me is that as a non native English speaker I can perfectly understand everything you're saying. This channel deserves at least 1 million subscribers and hundreds of thousands views. Keep it up, man. 🥂

  • @PrinceJeniFX
    @PrinceJeniFX 2 года назад

    YOU ARE MY NEW TEACHER RIGHT NOW ON RUclips. I WANT TO SET MYSELF ON A MISSION TO WATCH ALL YOUR JAVA VIDEOS! WELLDONE!!!

  • @jaspersumugat6951
    @jaspersumugat6951 Год назад

    Such a lifesaver, I'm currently working for our activity involving arrays and this video showed up. Very informative, no subtle introduction just worth of my remaining time haha. Thank you so much!

  • @kocovali7295
    @kocovali7295 11 месяцев назад

    my english its not so good, but you speak so clearly so nice i understand everything in your videos. As an Java beginner i am very very thankfull to you!

  • @miigon9117
    @miigon9117 3 года назад +7

    Cool video. So informative yet so clear and easy to understand. I’m learning java programming as a hobby language and your explanation is the best I have seen on RUclips!!!

  • @tatsueureka392
    @tatsueureka392 3 месяца назад

    I am studying from Udemy but I got confused because of the way the tutor explains. However, man you clear those confusions. Thanks man.

  • @tanu_matre
    @tanu_matre Месяц назад +1

    Best video on array and arraylist,on point....plz keep uploading ...it really helps 👍💫

  • @fractals330
    @fractals330 Год назад

    I'm using these videos to prepare for my first year Java course. Thank you so much!

  • @joren_combs
    @joren_combs 2 года назад

    Should point out that if you're stuck in a situation where you absolutely have to work with arrays, you can still use the Arrays utility class to provide some of these conveniences, which gives you e.g. Arrays.sort(arr), Arrays.copyOf(arr, len) for resizing, Arrays.toString(arr) for pretty array formatting, etc. You can also iterate over them with e.g. for (String str : strArray). At the same time, while it is true these capabilities are not strictly limited to Lists or Collections only, I do end up still using them almost exclusively for the reasons you shared; just the sheer productivity they provide for the time spent coding is usually reason enough to justify the overhead.
    Thanks for the video!

  • @keremgobekcioglu4686
    @keremgobekcioglu4686 2 года назад

    Liked this video , John. I have started to code in Java , after 1.5 year with C and C++. Now i'm learning some differences from you. Keep up.

  • @aravindhkumar69
    @aravindhkumar69 Год назад

    You are really superman.. Because your video helpful to everyone... I saw a video from tamilnadu in south India....... Your are my best teacher

  • @gabrielmicillo7763
    @gabrielmicillo7763 2 года назад +1

    This channel and its content its excellent.. im learning Java and I found it so much easier with these videos than my actual lectures. Also the edition of these videos is great. Please dont ever stop making videos about Java. I honestly think is by far the best there is on youtube, and all divided on little videos so it doesnt feel overwhelming like starting a new course.

  • @WoodyC-fv9hz
    @WoodyC-fv9hz 5 месяцев назад

    Wow. I compare you with my Java Prof at Uni Rheinland, Germany. He thought he was cool, but it took me long, to get the Java basics, while listening to his lectures. Your teaching method is amazingly more efficient in contrast to his. I am slow in my comprehension, not very intelligent, but within 15 minutes, you were able to help me resolving an issue revolving about some ArrayList-storage of Long Integers in the lower scale of billions of iterations and the numerical output in the order of a quadrillion (found some java JVM memory issues here). My bad programming :(
    I applaud your generous input into our Java community.

  • @wayneinteressierts9973
    @wayneinteressierts9973 Год назад

    Man, John! Thank you so much! I‘m about to start my first developer job and see your videos daily! You are so great help!!! Please keep going!

  • @mohamedmada4159
    @mohamedmada4159 3 года назад

    Glad that you've mentioned that ArrayList do so much behind the scenes, I'd have loved to see you go more in depth regarding the difference in speed and how they really work at a lower level, But again as you said the difference between both is barely noticeable.
    Thanx dude keep at it

  • @masikajenniffer6473
    @masikajenniffer6473 3 года назад +3

    This is amazing.The explanation is really easy to follow and understand. I hope many more people can watch and subscribe. Thanks for the tutorial

  • @Shamed33324
    @Shamed33324 2 года назад

    I normally do not comment on videos but I was very impressed by this video. I would not consider myself a newbie when it comes to coding with java. With that being said to often video do not go in-depth enough to to explain advanced questions relating to specific topics. Right now I am studying micro process relating to java. You answered my question on whether ArrayList are dynamic or fixed along with answer my question on whether or not this micro process would have a large impact on the run time. With that being said I still have one question about ArrayList you did not answer, ArrayList use the generic indicator "< >"(Dimond operator). I was hoping to learn more about how this aspect of ArrayList ties into its functionality. As of right now my understanding is that ArrayList work as a generic class, allowing it to take in/store a wide range of data types. if this is the case I would love to know more about how this ties into the fact it cant work with primitive types and only objects of type class(rapper classes). If you have any resources or information on why ArrayList use the generics indicator "< >" I would love to look into it. Once again thank you for your very informitave video.

  • @aashishgupta9392
    @aashishgupta9392 2 года назад

    love from India bro....u know exactly how to teach....just amazing

  • @marcovalentinoalvarado3290
    @marcovalentinoalvarado3290 Год назад +1

    Just like Python has a Sentdex, Java has a John 💞💞 You guys are awesome!

  • @ghettoslick2000
    @ghettoslick2000 2 месяца назад

    Thanks i am currently taking java in college and your videos really help alot

  • @michaelekpo4011
    @michaelekpo4011 2 года назад

    Thanks Coding with John! One of the best videos I've seen throwing so much light on this subject.

  • @akshatmehra3951
    @akshatmehra3951 Год назад

    Awesome ! Learning java, coming from c++ and js background. This man has taught so much stuff so easily and quickly. Thanks a ton John !

  • @donnamadelene4594
    @donnamadelene4594 2 года назад

    i love how you explained this rn and em crying co'z I really don't understand it at first. so yeah thank you so much john.

  • @user-ec6ej4dp6t
    @user-ec6ej4dp6t 2 года назад

    I wish I started learning from youtube a month ago. Not learning anything in college programming. Going to school for Networking + Cyber security so this is my last programming class. You explained this better than my last 4 weeks in class going crosseyed.

  • @christpoic
    @christpoic 2 года назад

    Wow this explained clearly what i've learned in a 3 hours java course in univ.

  • @ahmetemin7572
    @ahmetemin7572 2 года назад

    this video really deserves that thumbs up. Tnx

  • @matiasmoresi5040
    @matiasmoresi5040 2 года назад

    Hey John! Thank you very much for taking the time to teach like this

  • @alvinashneel9124
    @alvinashneel9124 Год назад

    Bruh
    . Hope you gain a ton more subscribers asap.. ur the reason i started learning Java..

  • @bhuvaneshraj5405
    @bhuvaneshraj5405 2 года назад

    Best Java teacher ever

  • @SophoniasT
    @SophoniasT 2 года назад

    My first video and I just want to say that please keep going. This helped me in so many ways. Easy to understand explanation and very helpful interaction. God bless you. You have a subscriber! 🙏🏽👏🏾👏🏾👏🏾👏🏾👏🏾

  • @nicholi8933
    @nicholi8933 2 года назад

    This was super useful. I was forced to use an arraylist in this program and everything I was doing was not working. Though mine is a bit different since they are class objects, I figured it out with your help. Thank you so much. Arraylist remind me of arrays in python.

  • @TornadoeJoe
    @TornadoeJoe 3 года назад +6

    Thanks for the help! Java is an interesting language so far, and this definitely helped me see things a bit better.

  • @nathanelliott9729
    @nathanelliott9729 3 года назад

    Thank you so much, I learned more from this video than a 2 hour lecture from my professor.

  • @KyleHarrisonRedacted
    @KyleHarrisonRedacted 2 месяца назад +1

    I think the thing missing from your oherwise excellent tutorial here is _why_ you'd want a fixed array vs a dynamic one. Really, everything a fixed array can do, a dynamic one can as well, so why bother with the headache?
    And the answer is performance. Heap Memory allocation is expensive, and an array uses contiguous memory; so when a dynamic array gets added too and grows and there's not enough room for expansion in contiguous memory, the whole thing gets copied to a new location where there is room, with the old one marked to be swept for later. This is a very slow and cpu intensive operation. But it's useful for the types of situations where you don't know for sure how big or small something might be up front.
    But if you know you're generating a 2d map of 32x32, use fixed. If you know you're getting at most 5 records from your database, use fixed. Why? Because when declaring the fixed array variable it allocates enough general memory to store that many of that object or primitive, once. Overwriting an element's null or existing value with another value is a _faaarrrrr_ less expensive operation. And while the conveienice of a foreach loop is indeed a nice and safe way to loop, don't forget there's nothing really wrong with setting some upper limits where it makes sense, and definitely saying "hey this is exactly how much memory I will probably need to do this", hydrate the elements with the values you get, and during your normal for loop through the data just check for null and break out. Always ask yourself when you creating a dynamic array... do you _actually_ need to be adding and removing elements? If the answer is yes, go for it, but you might be surprised to learn just how often you dont need it.
    But I still wouldn't use the the actual "fixed" arrays, those method the ArrayList wrapper comes with are just too handy. But if you supply an integer into the contructor of the ArrayList? It'll create the intiial array with that many values once_. ( `new ArrayList(500)` ) That gives you _all the benefits of what the fixed array does, with all the benefits of what the dynamic array wrapper provides (including the ability to add and remove elements if you must)

  • @sweetshoez
    @sweetshoez Год назад

    Thanks again this is exactly what I needed coming from more user-friendly languages

  • @edwindeva007
    @edwindeva007 Год назад

    Awesome way of teaching John.. please don't stop teaching at any cost. This really helps a lot of people !! you deserve more subscribers

  • @javierherrero7011
    @javierherrero7011 2 года назад

    John, you are an excellent excellent teacher....I have seen many of your Java videos, always learn fast and solid

  • @maryozonkwor-ei8vw
    @maryozonkwor-ei8vw 7 месяцев назад

    Just what i am looking for. And u explain like swift and smooth . Tnx

  • @patrykgwardzik4509
    @patrykgwardzik4509 2 года назад

    Man i just love you so much. This is so clear and understandable.

  • @HatTrick4030
    @HatTrick4030 Год назад

    Awesome!! as a refresher I alwasy have to come back and re-study the already-studied topics. Thanks for this great video

  • @xxxiao717
    @xxxiao717 3 года назад +10

    Very clear and detail, it really helps a lot! Will subscribe and hope to see more videos soon!

  • @danhk852
    @danhk852 3 года назад

    Yet another great walkthrough. This channel has been such a huge help in my own Java journey.

  • @Stl71
    @Stl71 3 года назад

    Hope your channel grows that much, that all the subscribers don't fit in an ArrayList...Subscribed!

  • @jonathanfinke251
    @jonathanfinke251 2 года назад

    It was the carl flash for me I wasn't preparing for that gave me hope on hour 400 of preparing for my java final. Subscribed.

    • @CodingWithJohn
      @CodingWithJohn  2 года назад

      I knew I put those in there for a reason.
      Good luck on your final!

  • @charmainemarasigan8994
    @charmainemarasigan8994 2 года назад

    Superb training. Not boring! Very educational! Highly recommended

  • @raba650
    @raba650 2 года назад

    What a great walkthrough! Really enjoyed it. Now to binge on some more of your videos :)

  • @Cosmos0000
    @Cosmos0000 Год назад

    Having spent a semester learning and working with C (and now learning Java in my CS classes), I have to say that the dynamic size of array lists sure does have me excited :D

  • @qararander
    @qararander 2 года назад

    Thanks. Your lessons are great. You simplify matters, you consider students cognition over showing your talent, which you undoubtedly have. Some teachers focus on proving their excellence more than a student’s need, level and ability.

  • @AnaCristina-ve7wh
    @AnaCristina-ve7wh 8 месяцев назад

    Thanks, you're a great teacher!! It's incredible how you can make it so easy to understand

  • @KJ7JHN
    @KJ7JHN 2 года назад

    passing an arraylist to a method? Keep up the great work!

  • @jordans3611
    @jordans3611 2 года назад

    Keep this up man, your videos are helping me so much!

  • @Manker00
    @Manker00 2 года назад

    Good video. Only thing I would like to add: You can add and remove elements when working with arrays, even if not directly. You would work with javas copy methods to do so.

  • @ZeroMilesTravels
    @ZeroMilesTravels 2 года назад

    Hay John, Thanks for the beautiful tutorials, its littel hard to understand you as i am very biggner, but eventually you made your point very clear.