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

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

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

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

    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 Год назад +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 Месяц назад

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

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

    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

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

    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.

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

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

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

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

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

    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.

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

    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

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

  • @robertjr8205
    @robertjr8205 7 месяцев назад +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!

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

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

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

    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.

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

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

    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!

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

    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 ❤️

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

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

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

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

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

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

      I Second that

    • @CheeseStickzZ
      @CheeseStickzZ 2 года назад +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

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

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

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

    This video took me only 17 mins to get fully understand the basic concept of Array and ArrayList.
    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!!!!

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

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

  • @CoolBear619
    @CoolBear619 10 месяцев назад

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

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

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

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

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

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

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

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

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

    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.

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

  • @IronMeDen1
    @IronMeDen1 4 дня назад

    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!

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

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

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

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

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

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

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

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

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

  • @mastermatt6090
    @mastermatt6090 7 месяцев назад +1

    Thanks dude, you make everything so simple!

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

  • @tanu_matre
    @tanu_matre 7 дней назад +1

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

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

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

    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 Год назад

      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?

  • @user-ec6ej4dp6t
    @user-ec6ej4dp6t Год назад

    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.

  • @fractals330
    @fractals330 10 месяцев назад

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

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

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

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

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

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

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

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

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

  • @stingray-q5p
    @stingray-q5p Год назад

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

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

  • @tbone587
    @tbone587 2 года назад +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

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

    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!

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

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

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

    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.

  • @ghettoslick2000
    @ghettoslick2000 27 дней назад

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

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

    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.

  • @KyleHarrisonRedacted
    @KyleHarrisonRedacted Месяц назад +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)

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

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

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

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

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

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

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

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

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

    I’m here because I’m writing OCA in 5 weeks, I love how you explain and on point on what is expected. I would love to go through your learning but I see you not available on UDEMY

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

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

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

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

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

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

    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! 🙏🏽👏🏾👏🏾👏🏾👏🏾👏🏾

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

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

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

    Its mind blowing how your channel has so few subscribers....

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

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

    I’m new to Java and need to learn for my job. Thanks for the videos!

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

    You would be an amazing CS professor, thank you for saving my degree 🙏

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

    Thanks for this video. I googled ArrayList and Linked list and got a LOT of sites but non of them made sense to me and a few of them just made me more confused.

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

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

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

    Why am I paying thousands to learn this at college when youtube is so much better

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

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

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

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

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

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

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

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

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

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

    I found the video extremely useful, as I had not used arraylist before always stuck to conventional arrays.
    I did however come across a situation that confused me for a while, I was loading the array dynamically so I thought, however in fact the loop was not running correctly which is another story, so the array did not get filled, so I kept getting an out-of-range error when I tried to retrieve the string at location (10) as it was not there!
    So, the watch word here is if you are doing things dynamically make sure they are working first

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

      Always a good idea to test everything as early as you can

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

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

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

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

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

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

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

    I’ve been using Collection Lists for so long, I forgot that the Java Array was fixed size! 😂 Thanks for the reminder.

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

    this video really deserves that thumbs up. Tnx

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

    I just noticed that sweet Kramer portrait behind you Haha

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

    Love your classes! Question. Which IDE are you using?

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

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

    Hello John. Your videos have always been very helpful. Could you make a playlist explaining Java Collections and all sorts of Map completely?

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

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

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

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

    John, This video is amazing. Now I can actually explain the difference between Arrays and Arraylists better with an example in my next interview. I made a note of the source code and bookmarked your video. 👍

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

    If arraylists were a product, then you just sold me your entire stock!

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

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

    Nice video John, but with one little flaw. You don't need to write a loop to print an array.
    String[] names = {"Amy", "Naomi", "Lovina"};
    System.out.println(Arrays.toString(names));

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

    Please make more videos. I really like your teaching style. Thanks...