You kinda left out the main point of Polymorphism. The conclusion should be that you can store all the different instances (e.g. of Dog, Cat, ...) in Animal variables and it still does the proper thing! Usually you e.g. have a List which contains different animals, and you can just call the eat() function on each element without worrying what type it actually is.
@LitchBeats3 жыл бұрын
This guy is way too underrated 🔥
@electronoob73413 жыл бұрын
Yes!
@MrSkinkarde2 жыл бұрын
Boring stuff
@SakkePie2 жыл бұрын
@@MrSkinkarde why are you watching if you're not interested 😂
@sauravrajmitra68042 жыл бұрын
He was born to teach Java
@turuus52152 жыл бұрын
@@MrSkinkarde You're Finnish, aren't you?
@electronoob73413 жыл бұрын
My Univ. professor couldn't explain it to me like this over a whole semester! Now here I am understanding it in under 10min. Thank you!
@King-cv6mn2 жыл бұрын
Perhaps you should have come here first
@michimarz Жыл бұрын
John has some very good videos, but this one is kinda disappointing, I'd say. It's not exactly polymorphism what John is explaining here. It's more like he's only describing inheritance. That said, I think you should have listened more carefully to your Professor instead.
@techatival Жыл бұрын
"If you can't explain it simply, you don't understand it well enough." - Albert Einstein
@Pratik_yadaw Жыл бұрын
maybe bc you love dogs and cats
@justspacing9031 Жыл бұрын
@@michimarz What? Did you even watch the video?
@travismaurice63082 жыл бұрын
Dude. You really just saved my entire life. I was having so much trouble understanding how to explain polymorphism and putting it into my own words. You explained it so perfectly in so many ways. Great content!
@mmq6525 Жыл бұрын
lol entire life? a little dramatic aren't we
@smeboo9044 Жыл бұрын
@@mmq6525got somethin’ to prove now do we?
@EkThaKingMan Жыл бұрын
@@mmq6525 bros got gun to his head by boss as we watch
@feynthefallen8 ай бұрын
It's always nice to see you still got the basics down, even though I think I never EVER went and thought "I'm gonna use polymorphism on that sucker", but just went and did it.
@menaaziz273 жыл бұрын
Subscribed! with polymorphism also you can always assign a subclass object type to a super class reference type like that Animal cat = new Cat(); Animal dog = new Dog(); Animal a = new Animal(); Since Animal cat = new Cat() | | | | Reference type object type Happy coding everyone.
@MrSelmanceltiker2 жыл бұрын
Actually this is the correct explanation of polymorphism. The video content explains inheritence mechanics of OOP. Inherıtance provides child class type object act like parent class type object by inheritence. Polimorphism provides parent class type object can act like chıid class type object. Internal mechanics are very different.
@elizaalwani92002 жыл бұрын
So does the reference type or object type determine which method is used
@KaraSuraDraw12 жыл бұрын
@@elizaalwani9200 The object type
@brutusjackendy36582 жыл бұрын
@@elizaalwani9200 The object type does.
@nolan_villeneuve2 жыл бұрын
@@elizaalwani9200 the object type does. BUT the availability of methods is determined by the reference type.
@1337-p3h3 жыл бұрын
Very good videos. You explain things in ways that eliminates confusion and covers all bases.
@mrtoast2442 жыл бұрын
John is so concise in his teaching, my lecturer literally takes two hours to cover the exact same concepts
@eternalflames911 Жыл бұрын
memento mori
@mrtoast244 Жыл бұрын
@@eternalflames911 🖤🤍
@firasjab2 жыл бұрын
I think what you have described here is simply inheritance & method overloading. Polymorphism is a bit more advanced than that. You could for example have declared the cat and dog objects as Animal. That would at least have introduced the concept of polymorphism.
@insertname615 күн бұрын
What he explained could be called as polymorphism, specifically early-binding or compile-time polymorphism. What you are talking about is late binding or runtime polymorphism. Java can do both. But, yeah he did miss out on the runtime polymorphism.
@SoundSpaceStation Жыл бұрын
I always wonder why University teachers spend whole semester to explain the topic but you still don't understand, but here on you tube you watch 7 minutes video about the topic and fully understand what the heck it is all about . Thank you John very much for your great content!
@eric.m5790 Жыл бұрын
University teachers are not programmers. If you want to learn how to swim i think its best to learn from someone that already knows how to swim
@michimarz Жыл бұрын
John has some very good videos, but this one is kinda disappointing, I'd say. It's not exactly polymorphism what John is explaining here. It's more like he's only describing inheritance. That said, I think you should have listened more carefully to your Professor instead.
@JJJJ-gl2uf Жыл бұрын
Surely your college teachers aren't spending an entire semester explaining one concept to you. Java [programming] doesn't come easily or quickly to everyone, maybe hit the books a bit harder or do what you're doing here: supplement your college lessons with YT videos.
@lisahlee56783 жыл бұрын
You have no idea how I struggled to understand this, about 5 hours before exam i stumbled upon this video, thank you. It was super easy to understand, never thought someone could explain polymorphism this way
@amphousee6 ай бұрын
2024 and this is still the best short explaination of polymorphism on KZbin.
@piotrek76335 ай бұрын
Maybe theyre wrong
@madmalik27762 ай бұрын
I struggled with understanding polymorphism after reading the entire chapter twice, but I finally grasped the concept after watching this 7-minute video. Thank you so much for the help!
@darylbaptie5159 Жыл бұрын
Thanks John! After hours of trying to find a clear explainaton you wrapped it up in 7 minutes, thanks again!
@ainsleys4402 Жыл бұрын
I don't know how to express my gratitude dude, you've saved me. I've been struggling really hard with my Java class and you have a gift for explaining in a way that scratches my brain the right way.
@cristhianjesus89789 ай бұрын
You are an amazing teacher, know that. I've been doing a lot of java courses and these topics are always convoluted and extremely difficult to understand, but you've managed to explain in a simple way. Thanks!
@daniaaguila98242 жыл бұрын
Hi John, thanks for your Java tutorials with non-monotone voice. If you can explain more about composition and aggregation in Java that would be great (your explanations are easier to digest compared to other youtube tutorials)!
@vaio0072 жыл бұрын
The best Java programming youtuber !! Wish I had known his channel back in 2021 beginning when I started the programming module in Uni.. Explains way better than many of my lecturers ! Thank You !!!
@RJones-mx2oi2 жыл бұрын
I really wish I had found you and your channel months ago. Even though you are speaking fast, I am grasping and retaining the concept to write into code. Thank you so much!!!
@ironbirdstudios11 ай бұрын
i usually never comment on videos, but this guy deserves it all. help me finally end my struggle with CSE 205.
@jimmysmith94622 жыл бұрын
That was such a simple explanation that was being made WAY too complicated in my class. Thank you for putting this stuff out there.
@maniac75912 жыл бұрын
Great explanation. I've been trying to study up for an interview (has been years since I graduated and been in a different field so I forgot everything). When I was studying it wasn't clear that method overriding and method overloading were part of Polymorphism. They made it seem like they were totally different things so thank you for clearing it up!
@fallennarcotic69812 жыл бұрын
You have not fully understood a problem if you can not explain it to someone else. This guy is an expert in his field making the explanation affordless
@rizcmt1953 жыл бұрын
excellent spent 2 hours watching diff videos to understand the concept but you explained way better and way easy from all of them
@shankar74352 жыл бұрын
I guess what was explained in the video is inheritance. As someone commented " Inherıtance provides child class type object act like parent class type object by inheritance. Polymorphism provides parent class type objects that can act like chıid class type objects. Internal mechanics are very different."
@Molotom3 жыл бұрын
Thanks for the video! You're helping a beginner coder in college out quite a bit :)
@xenophage5562 Жыл бұрын
This was a fantastic explanation that I was able to wrap my head around, bravo good sir!
@vanshika.singh.12 жыл бұрын
The fact that this was explained so perfectly and clear and it just clicked so well. Amazing job done!
@prathapkoththigoda94713 жыл бұрын
It was a nightmare to find a video to understand Polymorphism. Thanks a lot.
@alexeysytnikov62204 ай бұрын
Amazing explanation, John! Can I overload a class constructor?
@smaziano16 күн бұрын
Just wanted to point that you have a good sense of humor… all this based on the Kramer picture in the back… legendary
@howaboutsomesoyfood2 жыл бұрын
straight to the point way of explaining this concept, most others just over-complicate it and are needlessly verbose.
@thezopelo Жыл бұрын
Thank you for the clarification on overloading vs overriding.
@NYUCODERS7 ай бұрын
He made it Simple. Thank you 😊
@being_sentient Жыл бұрын
Hi. I am learning Java and I frequently drop here to get things straight. This video does a very good job of introducing polymorphism in a simple manner. But what I would also like to add, is spending some time to explain compile-time and run-time polymorphism. You can do one better by disclosing what polymorphism generally is(that is in the natural world) and how we can try to effect the same phenomenon to objects in Java (since objects in OOP languages mirror real-world objects). There are two ways to imbibe this phenomenon in an object in Java: at compile-time and run-time . The techniques of method overloading and method overriding then happened to be just a natural consequence of acheiving the desired effect. I don't know if I got it backward. I felt the emphasis should be on the phases in the lifecycle of a program.
@RefaatIbrahimXIT5 ай бұрын
Polymorphism is overrider & overload Parent methods. Thank you John
@eetulaakso53743 жыл бұрын
Thank you! I'm so happy that I found your video. I definetely watch other content from you, since you explain this topic so clearly. This makes so much more sense even in English compared the videos of my native language in which I just don't understand this subject at all.
@NatanStarke2 жыл бұрын
Long time im out of programming life but seeing this video kinda make me happy remembering some stuff. Also very good explanations!
@crawfishmedia2 жыл бұрын
I'm in a Java course and wasn't understanding this topic. Now its perfectly clear. THANK YOU!
@tryfonmichalopoulos56563 жыл бұрын
0:38 - "morphism" actually originates from the greek word "morphi", which directly translates into the english word "form".
@CodingWithJohn3 жыл бұрын
Cool! Got it right and didn't even know it 👍
@ChrisLevi22 Жыл бұрын
this guy explained a concept in 7 minutes so much better than my professor could in 2 hours. Unreal man. Such a lifesaver
@devangprabhune35912 жыл бұрын
You're way of explaining is playful and very expressive. ❤️ it
@roverojermainemariongilr.28563 жыл бұрын
O that's great and I'm learning more on your channel! Thank you for this! Love from the Philippines!
@agreizda43235 ай бұрын
I am currently studying for my finals exam in Germany and this is just perfectly explained. THANKS!
@TheRebelMerchant3 жыл бұрын
excellent video. I am a CIS student this is now starting to all make sense.
@surajpatel4073 Жыл бұрын
Yo, can u make a video on explanation of Method Overriding in JAVA ,would really love to watch your explaination
@MyLe-wc5dg3 жыл бұрын
Heyy thank you for this video. Your pronunciation as well as explanation are really easy to understand for a Vietnamese student like me. Keep uploading more informative video please 🙏 Have a nice day ☺️☺️
@zero_n_one37823 жыл бұрын
Thank you for the videos. I have humble request for you to make a clear and understandable videos regarding polymorphism via inheritance and polymorphism via interface and passing an object as argument. Thank you once again for good video.
@PremChand-sb3vq3 ай бұрын
Wow!!! Extraordinary skills on explaining the concepts🎉
@juicifer20242 жыл бұрын
Explaining what my comp sci professors couldn't explain during lectures...I do realize you have the benefit of hindsight and editing to make videos go a lot smoother than lectures, and there absolutely is value to lectures since we can actively ask questions and receive answers...But the way you structure your videos has been all but confusing thus far. Love this page.
@holy87822 жыл бұрын
You've explained what this is and how to do it in half the time and made it 10x more interesting than my instructor. No insult to him. But he just made it sound way more complicated than it actually was.
@michimarz Жыл бұрын
It's because polymorphism is unfortunately more complicated than what he's saying here.
@LizyAd26 күн бұрын
This was clear and concise. Thanks
@tanyashankar16642 жыл бұрын
Hi,John...you made my life so easy..was struggling to understand the polymorphism concept until i found your video...much love from india
@FifiToJaITylkoJa2 жыл бұрын
ay yo dont delete comments that actually explains what polymorphism is.
@thomass18912 жыл бұрын
I was going to quit my programming course and go back to working at Sonic, but then I came across your video and it just clicked. NO exaggeration, God bless you.
@MYTHIICOOL7 ай бұрын
John you might be one of the best tutors on KZbin🙏🏼
@Raccoon_In_A_Suit6 ай бұрын
Words fall short to convey how helpful this lecture was sir.Thank you ❤❤
@stopfbums Жыл бұрын
Wow this is just amazing. Currently studying computer science and you help me so much!
@lazarus8011 Жыл бұрын
Jonny Sins is the best at teaching programming
@linkedprosperity2 жыл бұрын
So fun with John...geez I have to get his training...makes Java fun.
@jenniferr20332 жыл бұрын
Explaining things better than youtubers with 500k+ Subscribers ...John you are doing gods work thank you so much
@protocolcode27033 жыл бұрын
Thank you so much. I was looking at a video at linkedin learning an I was about to quit learning java due to that video. You made it so simple and easy. Thank you from the bottom of heart.
@waheed-ou4ek7 ай бұрын
I'm speechless for this great tutorial ever.... Earn my subscription....!!! Very simple to understand....!!!!
@heartoutloud74982 жыл бұрын
Ur explanations are as clean as ur code John. Thank you
@textinface1 Жыл бұрын
Amazing explanation. I'm sure you already know but your teaching skills are helping thousands of students including myself. Thank you so much!
@arno54053 жыл бұрын
Well done my guy. Great video
@ibrahimaminu40452 жыл бұрын
Man how did i only find this channel now great content so easy to understand concepts the way you explained in this video!!
@kathrinm242010 ай бұрын
You really are a great explainer, thank you! I also didn't get the concetp at uni
@emilyoldson82132 жыл бұрын
Just found you today and am so thankful I did! Thank you!!
@student02062 жыл бұрын
I believe this is inheritance and not polymorphism. The subclasses of cat and dog are inheriting the superclass Animal's data fields and methods. Welp, off to find a polymorphism video! Good luck to all!
@Curiousgoogler7 ай бұрын
Thank you sir for making this concept easy to understand.
@Htman11 ай бұрын
Yoo John you are incredibly brilliant at teaching Java.
@lootster5 ай бұрын
I don't understand why nobody can explain Polymorphism in such a simple yet elegant way!
@sujitsharma47923 жыл бұрын
Very well explained... It will surely lead to Subscription++
@FazalMalik2 жыл бұрын
I just watched your video , I am little bit confused, you made it very easy to learn coding.
@TheRealFenwick3 жыл бұрын
Thank you so much John! you have helped me so much with my internship! Shout-out from Australia
@lucifersenpai19482 жыл бұрын
Watching this video i exclaimed three times "Wow! this guy is great". Subscribed.
@theNorth4733 жыл бұрын
Unbelievably clear. Thank you!
@increment-8 ай бұрын
2-3 uni lectures in 7 minutes, ur amazing!
@yaknuelgh2 жыл бұрын
God bless any KZbinr including you John who teaches coding.
@Alibeee872 жыл бұрын
Thank you for helping me get through my first year as a graduate student!
@nunya11203 жыл бұрын
Your channel is still very new, but wow, if you keep this up you're going to grow exponentially. Love your content please keep it up.
@novanoskillz41512 жыл бұрын
wow, i have asked and "re-asked" my professor to explain this to me. and i just wasnt getting it. ive learned more in the first 3 minutes of your video then what my prof. has been trying to explain to me in 4 weeks. Thanks so much.
@bemeb41yashsakpal90 Жыл бұрын
This guy knows the art of teaching, he explained all the concepts in such a smooth way, he makes learning fun & interesting 😇👍
@lit_lay Жыл бұрын
I was really confused but after watching this, I realized that I have done this in my program already but I don't know it's polymorphism .. thanks
@liadp51172 жыл бұрын
very well explained
@sigfigronath2 жыл бұрын
Thank you, please do for the other 3 java core concepts as well!
@alanfang766510 ай бұрын
Thank you for explaining the topic so well..... I found your material way easier to digest than my java class! Doing God's work out there.
@paulsnehasish58302 жыл бұрын
for beginners: Method Overloading is categorized under Compiletime polymorphism and Method Overriding is categorized under Runtime Polymorphism
@giaccommander74742 жыл бұрын
I learned the theory about 5 times but never had to use it because didn´t find a job as juniorDev. but this time I think I got it. THX John.
@youvegotmail93852 жыл бұрын
My dude is awesome. Would be awesome to work under someone with his knowledge...and humor.
@carina.zip20022 жыл бұрын
My comp sci final is in two days and you are the only reason I'm not crying right now.
@cutecatshorts34642 жыл бұрын
man I'd love to watch spring videos you create
@Moch1172 жыл бұрын
Not sure if you'll see this comment but here goes: I been watching your video on Polymorphism and Inheritance. I understood everything until now where I saw syntax when declaring a new object such as this: Beverage temp = new Coffee(); //Coffee is a subclass. There is an inheritance to this : class Coffee extends Beverage { etc,,}} I always thought instead of reading Beverage, this must have the same name as the Constructor i.e it should say Coffee temp = new Coffee(). Does this work because Coffee is a subclass of Beverage? And with the code above, does this mean temp is now an instance of the Coffee class rather than Beverage class?
@CodingWithJohn2 жыл бұрын
I do read every comment on all my videos (except possibly replies, cause the notifications are weird for those). I don't have the time to reply to all of them, but I do read them. In short, you're correct. Coffee is a subclass of Beverage, which is often known as an "is a" relationship. Coffee "is a" Beverage, so Java allows that. You could even have a subclass of Coffee like "ClassicRoast", and you could do: Beverage myBev = new ClassicRoast(); or Coffee myCof = new ClassicRoast(); All ClassicRoasts are Coffees, and all Coffees are Beverages. But not all Beverages are Coffees, and not all Coffees are ClassicRoasts. However there are some subtleties about how those objects are treated when you make them like that. One of my recent videos is all about upcasting and downcasting and it talks about this extensively. I think it will answer a lot of your questions: kzbin.info/www/bejne/fqHYeWqkbruCj80 Great question, and thanks for watching!
@diodesu2 жыл бұрын
Binge watching this man's videos. He's something else!
@bioblade872 жыл бұрын
awesome video. The code examples really help too! I use method overloads all the time in c# systems class but didn't know it's a result from polymorphism. Thanks
@R3Z3R3CT10N2 жыл бұрын
Well, enjoyed all the munchs, chomps, and noms while learing something again in a new way. Was grateful this was in my feed/recommendations.
@midnaite3 жыл бұрын
I'm struggling with the instantiation of the subclass. Well, it happens that the way I learned to do my instantiations is as it follows: SubClass object = new SubClass(); But some people do it differently, and that is the way that it is represented in the official Java documentation about Polymorphism: SuperClass object = new SubClass(); And I can't figure out why is this even a possibility, because when you instantiate objects with the second way, you can't access the SubClass methods (unless they are overrided methods and have the same name in both classes). Could you explain this to me? Because I noticed that in the video you did the instantiation the same way as I do. Thanks in advance.
@CodingWithJohn3 жыл бұрын
Great question! You can certainly do both, and using the superclass as the type has the limitations you noted. Most of the time, you're just fine using the SubClass as the type, as you describe how you usually do it. However, there are situations where it makes sense to use the superclass, such as specifically when there is a polymorphic method like you noted. Let's say you had an Instrument super class, and a bunch of sub classes of Instrument like Guitar, Trombone, Drum, etc. Your Instrument class could have a play() method that makes a sound, and all subclasses would override that method with their own implementation. You could write a method that looks like this: void playSound (Instrument instrument){ System.out.println("Playing my sound: " + instrument.play()); } This method doesn't know and doesn't care what type of instrument is passed in - it just needs it to be an Instrument, so that it knows it can call its play() method. If you want to use that playSound() method in that kind of situation, you have to create your instrument like: Instrument drum = new Drum(); playSound(drum); When working with collections, you'll probably run into similar situations, just with Interfaces instead of superclasses. For example, ArrayList is an implementation of the List interface. So usually when declaring an ArrayList, you should do this: List names = new ArrayList(); This list happens to use an ArrayList as its underlying implementation, but any method that takes a List of Strings doesn't care whether you use an ArrayList, or LinkedList, or whatever. Then you can have a method like this: void printNames (List nameList) { ... } Similar to the playSound() method above, this method doesn't care whether you used an ArrayList or some other kind of List implementation - it just needs to know it's some kind of List to do what it has to do. And the user of the method can use whatever type of List they want to use for their particular situation. That's a very long answer, but hope it helps clarify it a bit!
@midnaite3 жыл бұрын
@@CodingWithJohn I can't thank you enough for this!!!! It was really helpful. Thank youu
@MyLe-wc5dg3 жыл бұрын
I am having the same question. Thank you for asking @Jorge and thank @John for the best explanation 😭😭💕
@ArskaAdventures2 жыл бұрын
I just can't believe this. John actually helps people THIS WELL in the comments. I have no words. 👍👍👍
@kibuulekalembe47262 жыл бұрын
very helpful. Understood polymorphism and encapsulation in less than 30 minutes.
@Mike----5 ай бұрын
Once again, you make me hate Java less. Your videos are indispensable. 👍