No video

Checking Equality in Java ( == vs equals method )

This Java tutorial for beginners explains different ways to check if two variables are equal including ==, the equals() method, and Arrays.equals().
Specifically, we discuss primitive types including int, double, and boolean. Also included are explanations for the array class, ArrayList class, and String class.
Aligned to AP Computer Science A.
🔥 Subscribe To Get More Tutorials: bit.ly/36H70sy 🔥
🖥️ All Java Tutorials: bit.ly/JavaTutorialsKZread 🖥️
#Java #JavaTutorial #JavaTutorials

Пікірлер: 23

  • @BillBarnum
    @BillBarnum4 жыл бұрын

    📌 Subscribe For The Latest Videos: bit.ly/36H70sy 📌 . 💻 All Java Tutorials: bit.ly/JavaTutorialsKZread 💻 . 🤖 Learn Java In 3 Hours: bit.ly/JavaIn3Hours 🤖

  • @foamersimpson6690
    @foamersimpson669010 ай бұрын

    These videos are amazing and help me understand concepts that I didn't even know existed. Thank you bill!

  • @abhisheknagarkar6254
    @abhisheknagarkar62542 жыл бұрын

    Really liked your video.. Super awesome explanations with just the right amount of info so a person watching the video isn't flooded !

  • @BillBarnum

    @BillBarnum

    2 жыл бұрын

    Awesome, thank you!

  • @sergeiflozov91
    @sergeiflozov914 жыл бұрын

    Seems like there is a typo in 11:00 .. the quotation is not closed inside the parentheses of the println method in the second if statement! Your video is helping me a lot Thanks ^^

  • @BillBarnum

    @BillBarnum

    4 жыл бұрын

    Wow, good catch!

  • @glokta1
    @glokta14 жыл бұрын

    God bless you, I've been racking my brain against this for hours and this video was exactly what I needed. Very clear presentation. Your "Primitive vs Reference Type Objects in Memory" was also very helpful. Thanks a lot!

  • @BillBarnum

    @BillBarnum

    4 жыл бұрын

    Thanks for the feedback.

  • @satioOeinas
    @satioOeinas Жыл бұрын

    great video.

  • @makemusic1014
    @makemusic10143 жыл бұрын

    I wish u were my tutor

  • @Bettle
    @Bettle4 жыл бұрын

    Good job

  • @PrinceZam
    @PrinceZam2 жыл бұрын

    Wow this is really cool 🗣💯

  • @BillBarnum

    @BillBarnum

    2 жыл бұрын

    Thanks for the feedback. I'm glad you liked the video!

  • @kimsungho4114
    @kimsungho41143 жыл бұрын

    I watched all the ads for you :)

  • @cheribgh275
    @cheribgh2757 ай бұрын

    Hi Bill, can we initialize arraylist like this? List myList = new ArrayList(); I mean is this the right way?

  • @BillBarnum

    @BillBarnum

    7 ай бұрын

    That would be fine. Alternatively: ArrayList myList = new ArrayList(); ArrayList Video: kzread.info/dash/bejne/mn6jxLF8gLHUo8Y.html&pp=ygUOYXJyYXlsaXN0IGphdmE%3D

  • @ZXu-mj9gm
    @ZXu-mj9gm3 жыл бұрын

    👍

  • @BillBarnum

    @BillBarnum

    3 жыл бұрын

    Thanks for the feedback!

  • @RakibHasan-455
    @RakibHasan-4552 жыл бұрын

    7:44 can anyone tell me why it returns false,,, but in Arraylist it returns true..

  • @BillBarnum

    @BillBarnum

    2 жыл бұрын

    Good question. The Java object class includes an equals method that checks if the variables point at the same object. For classes, like arrays, that inherit the equals from the Java object class, using == and .equals() is equivalent. In classes like ArrayList, the .equals() method was overridden, and it actually checks the VALUES in the objects the variables are pointing at. In those cases, using .equals will return true if the two variables point at different objects with equal values. I don't have a video on it, but if you search KZread for "overriding equals java," you can learn what it means to override the equals method. If you want to learn more about inheritance in general, or overriding in general, I have some videos on those topics: kzread.info/head/PLmpmyPywZ443dRtMleUPoNp2OyiNE45O6

  • @RakibHasan-455

    @RakibHasan-455

    2 жыл бұрын

    @@BillBarnum Thanks man!

  • @sdanikazmi
    @sdanikazmi Жыл бұрын

    7:50 mistake on line a.equals(c) will be true.

  • @BillBarnum

    @BillBarnum

    Жыл бұрын

    Syed, This is an example of how confusing it can be to check equality in Java. While they are equivalent arrays, if you compare them that way, it will evaluate to false because the variables aren't pointing at the same object. At 11:20, I talk about the correct way to check the equivalency of two arrays.