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

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

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

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

    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 14 дней назад

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

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

    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 года назад +3

      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 года назад +128

    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 года назад +6

    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.

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

    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

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

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

    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

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

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

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

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

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

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

    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.

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

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

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

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

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

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

    Thanks dude, you make everything so simple!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    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

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

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

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

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

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

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

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

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

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

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

    Best Java teacher ever

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

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

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

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

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

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

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

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

    this video really deserves that thumbs up. 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 !

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

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

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

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

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

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

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

  • @KyleHarrisonRedacted
    @KyleHarrisonRedacted 17 дней назад +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

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

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

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

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

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

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

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

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

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

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

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

    I know this video is old, but thank you so much John!

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

    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

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

  • @Av-fn5wx
    @Av-fn5wx 11 месяцев назад

    Brilliantly explanation. Clear and concise ❤

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

    You are insanely good at teaching!

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

    Your are awesome man ❤️
    You teach so nice. You are adding every information about the topic into a single video. And also videos are not too lengthy.
    Loved to watch every videos you posted.
    Don't stop please.

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

    Superb training. Not boring! Very educational! Highly recommended

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

    You're such a great teacher. Thank you for what you do! I love 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

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

    Love the practical way you teach

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

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

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

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

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

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

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