I’ve “known” Generics for many years now but never really understood the difference between usage of wildcard vs a type parameter, even after having read the official docs a gazillion times. But your just one 15-min video has made everything crystal clear. Amazing! Thank You for making the video :)
Great explanation. I just have a stupid question for Cat. If you ask to shout(new Cat()) , a class, how is it that it prints 'meaw'? I didn't see clearly the class.
This is the greatest Java tutorial I have ever found on TH-cam. Not too lengthy, covered huge concepts within a few minutes. As well as clear and understandable English. Thanks.
@@YtubeUserr Yes, it's illogical to assign magnitude to a non-physical construct such as a concept, but if your comment was not about that and rather why generics are not important then I disagree.
This tutorial was so simple that I immediately implemented the generics very easily to one of the projects that I'm working on whereas a day ago I was just refraining from doing it just because of not being very confident with the Generics concept. Great stuff John, this was a very informative yet very simple to understand tutorial. Keep up the excellent work.
I'm Brazilian, I learned more in your class with you speaking in English than I normally learn in the classes I attend in Portuguese. Very good teaching. Thank you so much!
I just began my Education in Software Developing, one year passed and I've learned so much more from like 5 Videos from John than I've learned in the entire year, that's insane.
Honestly, this video clearly explains what generics is all about. It took me awhile to understand it but right here, it just takes 17mins of your time. Thanks for putting out great and concise content on Java!
This deserves an award for being the first perfectly clear guide on generics. I've done many courses and many java certified developer courses that fail to explain exactly how they work. Well done.
I literally love tutors who not only explain the way to write a code but also follow the technique of clearifying why we use this instead of that which is incredibly useful . Thanks a lot ❤❤
Among tons of courses I have ever seen and learned, I found out that Coding with John is the best. He explains confusing things in such an easy way. Additionally, his voice is so clear and easy to understand, that I can focus only on the code running on the screen, whereas I need to pay attention to reading cc in other courses. You're amazing, John!
At 16:00 I'm sure others might have had this question pop up in their minds as to why can't we just use private static void printList(List myList) instead of using the wildcard '?'. So although we could use the former format i.e. just with T in this case, but there's a difference between '?' and 'T'. 'T' means that your class or method will use classes of ONLY of type T, whatever T is defined to be, wherever a reference to T is made within the class or method, whereas '?' means that the class can be of ANY type. For deeper understanding of this difference, refer to the Generics chapter of the Java complete reference book wherein there's a specific use-case for when using won't work so one would have to use the wildcard '?'.
@@rohitsai806 Yeah sure. So the book is Java The Complete Reference (9th edition) by Herbert Schildt. You can easily get its pdf online as it's one of the most recommended books for Java. The wildcard sub topic is under Generics, chapter 14 in the book. The scenario that I'm talking about is mentioned there more clearly wherein you can only use '? ' and not 'T'
I am a junior Java back end developer, your tutorial is so efficient to explain everything clearly, thanks a lot . Recently, I review your video contents in spare time again and again.
There are just straight up some of the most perfect tutorials for someone like me, even 6 years in the Java industry and now upgrading to newer versions. Thanks John!
OMG i never knew i can learn these many things in 17 mins. Man i would love to work under tech leads like you. People like these improve quality of life as well
This is my first comment in TH-cam after many years , video had so much good content and value, Please Post more videos on generics in real time application , as production ready code that we use for configuring external dependencies Congrats John , Keep up the Good work ❣️
I didn't only understand generics with this tutorial, I also enjoyed watching it to the end! Video tutorials longer than 10 minutes often make me feel bored so can't follow them to the end without several pauses, but with John's video tutorials time just flies!
"extends" is called "upper bound", because the given parameter has to extend the given classe. (e.g. T extends Number, if you want to add numbers) "super" is called "lower bound", because the given parameter has to be a "super-class" of the given class. (e.g. you only want bigger mammals like cats, dogs and horses - and not rodents)
Hi Jhon, I know this tutorial is from 2 years ago, I'm new in this IT field, and I just wanna tank you so much for all your tutoriales, you have no idea how much helped me! Please continue to do this! You are a GREATE techer! Stay safe!
I'M SITTING HERE STRESSING TRYING TO UNDERSTAND WALLS OF TEXT FROM CANVAS AND YOU COME ALONG AND HAVE ME FEELING LIKE A PRO IN 17 MINUTES. I WANT YOU TO SIT HERE FOR A SECOND AND TRULY TAKE IN HOW MUCH TIME AND EFFORT YOU'VE SAVED ME AND THEN MULTIPLY IT TO THE HUNDREDS OF THOUSANDS OF PEOPLE THAT HAVE WATCHED THIS. SERIOUSLY TAKE IN THE IMPACT THAT YOU'VE HAD AND PAT YOURSELF ON THE BACK. YOU DESERVE IT. THANK YOU JOHN!
I was looking for a short playlist/tutorial to understand the generics concept it was a bit confusing for me as you said. But this.. just one video cleared the concept. Thanks a lot! Keep making such videos👍🏻
The explanation was quite exceptional. i am a java engineer for 5 years and now only i got to know the full context of the generics.. thanks and keep feeding..
Great Video, but I'm confused on one thing, at 15:11 when you created the printList method , the Arguement was List myList and you said this is a list that will hold any type of object, but if you wanted the list to hold any type of object why didn't you just write List myList? Isn't that why one would use generics for like you explained in the video?
I never understand the right way of generics, I always have a kind of confusion about that, so here comes a 15-min video that clear everything. Just an amazing work! Thank you for make this video!
I've been a SDE for a couple years and found myself using generics forever without actually knowing what was going on. Thanks for the background and clear explanation!!
I know generics for a while. I remember my professor explaining about it and he spent kinda 9 hours, in 3 hours classes to explain what you have done in 15 minutes, unbelievable!!! Shout out to you!!! 👏🏼👏🏼👏🏼👏🏼👏🏼
Your videos are clutch. Your a life saver. My professor makes up a whole bunch of super complex examples when attempting to explain these topics to the class but just ends up confusing us due to the complexity of what his code is trying to do.
Beautiful Tutorial. It’s just amazing how you were able to explain this complex topic very easily. Keep it up John you are adding value to lives. God bless you for the good work you are doing sharing knowledge
This man is just awesome.....I wish I have a teacher like this person in my previous semester ... And I got to know him now finally god hears my prayers... don't stop these tutorials man.....these are life for people like us
lambda is straight forward. the main function provides the data and you perform the operation within the parenthesis ie someMethod(x -> x.result ? 1 : 0)
@@jaykay7932 Your terrible attempt at an explanation gone wrong is precisely why these videos are instead highly appreciated. Leave the explaining tho who knows how to do it
I don't think I can keep up at Johns level as Pinols says, I'm also beginner/struggling with lambdas a bit, but from what I have learnt is anything after the "->" or in the "{ }" after the arrow is like the contents of a function method, any variable before the "->" is the current item you are iterating through. (It kind of reminds me of Java callbacks in a way) hope this example syntax below might be useful, I'll use streams as an example it seems a great way to use lambdas // Without curly braces (1 liners) List numbers = new ArrayList(1,2,3); numbers.stream().forEach(number -> System.out::println); // With curly braces (multi-liners) List names = new ArrayList("Dave", "John", "Andrew"); names.stream().map(name -> { if (name.equals("Andrew")) { return true; } return false; }).collect(Collectors.toList());
Man, you changed my life with this video, i was having a lot of problems trying to unsdertand how(the first thing of my subject works) generics works and I hasn't found anywhere in my mother tongue, i was thinking that i wouldn't be able to understand how does that work until I found you! The explanation made me think by other perspective and made me confourtable to understand how does all of this works( even missing somethings like what does have on animal or how does exactly the try catch trow and trhows works) and now i'm ready to understand a lot more thigs of my classes. THANK YOU!!!!! SO MUCH!!!!!!!!! You are crazy man!
Hey John, thank for the tut! You made generics so simple to understand. Would love to see tuts on followings; Method referencing, Lambda Functions Optionals Stream API Thanks again.
Only if our university was this chill to teach something simply like you do. They start with complicated stuff and it gets nowhere in our heads. Thanks for the Tutorials.
I am literally afraid of generics in java. Could never understand what are T, V & ? . But your video made me understand the basics so clear. Thank you so much !!
This is the greatest Java tutorial I have ever found on TH-cam. Not too lengthy, covered huge concepts within a few minutes. As well as clear and understandable English. Thanks.😍
I am a beginner in Java and even though I don't know that much about Java I could easily understand most of the things in the video. I'm so happy that I came across your channel. Looks like this channel will help me a lot :D
I actually studied this extensively so many years ago and ended up implementing it for the DAOs used by the ORM in one of the projects I was assigned in in my previous company. To this day, I hear they are still using it as some sort of framework code for DAOs used by ORMs in that company even when I'm no longer around there. Watching this video reinforces the things I have learned and made me more confident that the things I learned when I studied it alone were correct. Kinda makes me feel that although it was an overextension of effort, it wasn't in vain.
So in your code you have : private static void PrintList (List myList) {} Couldn't you also do ??: private static void PrintList (List myList) {} They appear as though they work the same, so what's the difference, surely one is better than the other (or more dangerous to use if the compiler doesn't treat it the way we want) ?
Great crash course on Java generics. Each time during the video I was like "What about this situation", you covered it shortly after, which was great. Thanks.
Very Helpful! Clear concise and complete explanation. If someone is finding it a little fast please slowdown the playback speed and watch the video, it's really good.
Great video, thank you for the explanation! Tho I haven't noticed any info about why not to use generics everywhere. Googled a bit and found this: The only case when wildcards is the only option: Wildcards support both upper and lower bounds, type parameters just support upper bounds. So, if you want to define a method that takes a List of type Integer or it's super class, you can do: public void print(List
Hey man, I just want to say thank you. I've been struggling with this topic for a while now and now I feel a lot more comfortable working with generics after watching this video. You're the best!
One doubt: when you spoke about wildcards, you gave the example of passing a List of any class to a method. Instead of using wild card, we could've used this way right?: private static void printList(List myList) This works perfectly fine as well, then why do we need wildcards ?? 🤔
I went through a 3 hour lecture on OOPs and after that went through a couple of TH-cam videos but I was not able to fully understand what exactly generics were and why are they used. Then I came across this 17 minute video which cleared all my doubts and made everything super super simple. The difference a teacher makes is unbelievable. Subscribing and watching other videos too. Thank you so much!
I never understood this topic for years , I am having my interview tmrw this helped me a lot to understand it quickly.KEEP DOING THE GOOD WORK MAN !!!!❤
I did mountains of Java from mid-90's to 2010-ish, then focused on an architect role. I recently had to understand a new Java framework and it uses all these new Java features - I was having a hard time scanning through the code. THANK YOU for the clear and concise explanation.
Fantastic video. The "why" in the beginning is what really solidified my understanding as to why we need generics. I know how to use generics, but now I understand why we really need them! Thank you!
John, you are just a gifted teacher. Thank you so much for these videos. I've reached the age that I can never remember all the Java stuff I've learned, and I know I can get a quick refresher that will have me back up to speed by watching one of your videos. Or if I need to learn a new topic, I can just watch one of your videos and in a short time I'll be up to speed. Thank you so much.
You really know how to teach and get knowledge across. Some people are knowledgeable but don't know how to teach. I learn a lot from your videos. Thanks a lot.
Thank you so much for making your videos. I have problems with concentration of attention and memory, and it is difficult for me to listen, watch and read something for more than an hour. I am now in my first year at university and your videos help me so much to understand the material better and remember it for a long time.
First and foremost, I would like to thank you for your excellent teaching. I have been learning this topic for months, and now I have fully understood it. I would recommend providing the code used in the lessons as a zip file.
Thanks for clarifying the usage of each. I was mostly confused about ?, but it now makes sense that its used with collections rather than individual objects.
I failed an interview. One question is about Java generic which was introduced in 1.5. I never wanted to review it with details since I thought I knew it when I used the similar feature in C++ years back. It turns out I needed to. This video really helps in a sense covering pretty much every corner of this feature in an easy to understand way.
Hey John, thanks for the video, it's very informative. I got a question about the code in the video at 16:05. Why should I use and not in the example ?
I'm just quoting the video, from memory "...although Integer is a subclass of Object, List isn't a subclass of List..." Better watch it again. I had to :)
Such an excellent explanation of Generics. Before coming to this video, I was reading Head first Java and couldnt understand the Generics properly. Then I encountered your video and by the time I completed I have understood it clearly. Thank you for your passion . You are an amazing teacher. Good Day!
I’ve “known” Generics for many years now but never really understood the difference between usage of wildcard vs a type parameter, even after having read the official docs a gazillion times. But your just one 15-min video has made everything crystal clear. Amazing! Thank You for making the video :)
as for me, the best explanation was in Bruce Eckel's book "Thinking in Java", everything fell into place after reading this monumental book
yeah, I like to watch these videos, always has something we don`t know :p
Same here
Thanks, for this comment made me rewatch the end. Lost focus earlier :)
Great explanation.
I just have a stupid question for Cat.
If you ask to shout(new Cat()) , a class, how is it that it prints 'meaw'?
I didn't see clearly the class.
This is the greatest Java tutorial I have ever found on TH-cam. Not too lengthy, covered huge concepts within a few minutes. As well as clear and understandable English.
Thanks.
What are "huge concepts"?
@@YtubeUserrits a bot comment
@@YtubeUserr Yes, it's illogical to assign magnitude to a non-physical construct such as a concept, but if your comment was not about that and rather why generics are not important then I disagree.
My attention span was 5 to 8 minutes before watching this video, now it's 17 minutes. Thanks Jhon!!
This tutorial was so simple that I immediately implemented the generics very easily to one of the projects that I'm working on whereas a day ago I was just refraining from doing it just because of not being very confident with the Generics concept. Great stuff John, this was a very informative yet very simple to understand tutorial. Keep up the excellent work.
I'm Brazilian, I learned more in your class with you speaking in English than I normally learn in the classes I attend in Portuguese. Very good teaching. Thank you so much!
I had a Final exam on this topic and I can do it because of your clip! Thanks, John!!
Thanks so much, and great work!
Hands down, the best explanation I've ever seen. What a teacher.
I just began my Education in Software Developing, one year passed and I've learned so much more from like 5 Videos from John than I've learned in the entire year, that's insane.
have you been able to break into the tech industry? If so would you mind sharing how you did that?
Honestly, this video clearly explains what generics is all about. It took me awhile to understand it but right here, it just takes 17mins of your time. Thanks for putting out great and concise content on Java!
This deserves an award for being the first perfectly clear guide on generics. I've done many courses and many java certified developer courses that fail to explain exactly how they work. Well done.
I literally love tutors who not only explain the way to write a code but also follow the technique of clearifying why we use this instead of that which is incredibly useful . Thanks a lot ❤❤
Among tons of courses I have ever seen and learned, I found out that Coding with John is the best. He explains confusing things in such an easy way. Additionally, his voice is so clear and easy to understand, that I can focus only on the code running on the screen, whereas I need to pay attention to reading cc in other courses. You're amazing, John!
At 16:00 I'm sure others might have had this question pop up in their minds as to why can't we just use private static void printList(List myList) instead of using the wildcard '?'. So although we could use the former format i.e. just with T in this case, but there's a difference between '?' and 'T'. 'T' means that your class or method will use classes of ONLY of type T, whatever T is defined to be, wherever a reference to T is made within the class or method, whereas '?' means that the class can be of ANY type. For deeper understanding of this difference, refer to the Generics chapter of the Java complete reference book wherein there's a specific use-case for when using won't work so one would have to use the wildcard '?'.
Can you send the link to that book or explain which scenario ... will only "?" work
@@rohitsai806 Yeah sure. So the book is Java The Complete Reference (9th edition) by Herbert Schildt. You can easily get its pdf online as it's one of the most recommended books for Java. The wildcard sub topic is under Generics, chapter 14 in the book. The scenario that I'm talking about is mentioned there more clearly wherein you can only use '? ' and not 'T'
I am a junior Java back end developer, your tutorial is so efficient to explain everything clearly, thanks a lot . Recently, I review your video contents in spare time again and again.
There are just straight up some of the most perfect tutorials for someone like me, even 6 years in the Java industry and now upgrading to newer versions. Thanks John!
OMG i never knew i can learn these many things in 17 mins. Man i would love to work under tech leads like you. People like these improve quality of life as well
This is by far the best video on generics in the entire universe. Mad respect for this dude 🙏🙏
I have been using Java for more than 10 years now and have to admit that I hadn't understood generics so elegantly before. Thanks a lot for the video.
This is my first comment in TH-cam after many years , video had so much good content and value,
Please Post more videos on generics in real time application , as production ready code that we use for configuring external dependencies
Congrats John , Keep up the Good work ❣️
I didn't only understand generics with this tutorial, I also enjoyed watching it to the end! Video tutorials longer than 10 minutes often make me feel bored so can't follow them to the end without several pauses, but with John's video tutorials time just flies!
What I think it's missing is the generics that use the super word, like List, and explain the difference and the use cases of extends and super.
Yes pls explain wildcard with super keyboard
@@sameerkadgaye2048slammed my keyword
"extends" is called "upper bound", because the given parameter has to extend the given classe. (e.g. T extends Number, if you want to add numbers)
"super" is called "lower bound", because the given parameter has to be a "super-class" of the given class. (e.g. you only want bigger mammals like cats, dogs and horses - and not rodents)
Ur a dump
I know people tell this to you often, but let me remind you again John , you are THE BEST in java tutoring !
Another well-done tutorial here! Can't wait to see one on java 8 streams as I have not really found one that goes deep into these concepts.
Hi Jhon, I know this tutorial is from 2 years ago, I'm new in this IT field, and I just wanna tank you so much for all your tutoriales, you have no idea how much helped me! Please continue to do this! You are a GREATE techer! Stay safe!
I’ve never known anyone to explain things as easily as you do, fantastic video as always.
I'M SITTING HERE STRESSING TRYING TO UNDERSTAND WALLS OF TEXT FROM CANVAS AND YOU COME ALONG AND HAVE ME FEELING LIKE A PRO IN 17 MINUTES. I WANT YOU TO SIT HERE FOR A SECOND AND TRULY TAKE IN HOW MUCH TIME AND EFFORT YOU'VE SAVED ME AND THEN MULTIPLY IT TO THE HUNDREDS OF THOUSANDS OF PEOPLE THAT HAVE WATCHED THIS. SERIOUSLY TAKE IN THE IMPACT THAT YOU'VE HAD AND PAT YOURSELF ON THE BACK. YOU DESERVE IT. THANK YOU JOHN!
I was looking for a short playlist/tutorial to understand the generics concept it was a bit confusing for me as you said. But this.. just one video cleared the concept. Thanks a lot! Keep making such videos👍🏻
I’m working with c# and no nothing about Java but now I think I’m going to learn from this channel about both Java and c# . Thank you so much
You have quickly become my favorite Java tutorial TH-camr! Thank you for demystifying confusing Java concepts! :)
The explanation was quite exceptional. i am a java engineer for 5 years and now only i got to know the full context of the generics.. thanks and keep feeding..
Great Video, but I'm confused on one thing, at 15:11 when you created the printList method , the Arguement was List myList and you said this is a list that will hold any type of object, but if you wanted the list to hold any type of object why didn't you just write List myList? Isn't that why one would use generics for like you explained in the video?
This man taught me generics and wildcards better than my professors ever did. Thank you. You saved me :')
I never understand the right way of generics, I always have a kind of confusion about that, so here comes a 15-min video that clear everything. Just an amazing work! Thank you for make this video!
I've been a SDE for a couple years and found myself using generics forever without actually knowing what was going on. Thanks for the background and clear explanation!!
This video reminds me the quote “If you can't explain it to a six year old, you don't understand it yourself”
Best concise explanation of Generics ever filmed.
I know generics for a while. I remember my professor explaining about it and he spent kinda 9 hours, in 3 hours classes to explain what you have done in 15 minutes, unbelievable!!! Shout out to you!!! 👏🏼👏🏼👏🏼👏🏼👏🏼
Your videos are clutch. Your a life saver. My professor makes up a whole bunch of super complex examples when attempting to explain these topics to the class but just ends up confusing us due to the complexity of what his code is trying to do.
Beautiful Tutorial. It’s just amazing how you were able to explain this complex topic very easily. Keep it up John you are adding value to lives. God bless you for the good work you are doing sharing knowledge
This man is just awesome.....I wish I have a teacher like this person in my previous semester ... And I got to know him now finally god hears my prayers... don't stop these tutorials man.....these are life for people like us
*Hey John, can you please make a video on lambda expressions in Java? Would really appreciate!*
Waiting for Lambda, Functional Interface, Streams
@@akshaylonkar713
l -> ( th-cam.com/video/d3_vmdKSE3c/w-d-xo.html )
lambda is straight forward. the main function provides the data and you perform the operation within the parenthesis ie someMethod(x -> x.result ? 1 : 0)
@@jaykay7932 Your terrible attempt at an explanation gone wrong is precisely why these videos are instead highly appreciated. Leave the explaining tho who knows how to do it
I don't think I can keep up at Johns level as Pinols says,
I'm also beginner/struggling with lambdas a bit, but from what I have learnt is anything after the "->" or in the "{ }" after the arrow is like the contents of a function method, any variable before the "->" is the current item you are iterating through.
(It kind of reminds me of Java callbacks in a way)
hope this example syntax below might be useful, I'll use streams as an example it seems a great way to use lambdas
// Without curly braces (1 liners)
List numbers = new ArrayList(1,2,3);
numbers.stream().forEach(number -> System.out::println);
// With curly braces (multi-liners)
List names = new ArrayList("Dave", "John", "Andrew");
names.stream().map(name ->
{
if (name.equals("Andrew")) {
return true;
}
return false;
}).collect(Collectors.toList());
Man, you changed my life with this video, i was having a lot of problems trying to unsdertand how(the first thing of my subject works) generics works and I hasn't found anywhere in my mother tongue, i was thinking that i wouldn't be able to understand how does that work until I found you! The explanation made me think by other perspective and made me confourtable to understand how does all of this works( even missing somethings like what does have on animal or how does exactly the try catch trow and trhows works) and now i'm ready to understand a lot more thigs of my classes. THANK YOU!!!!! SO MUCH!!!!!!!!! You are crazy man!
Sensational lecture! Dude, please become a computer science professor! Your lectures are the best! Thank you so much.
Gosh I have been wasting my life trying to understand this concept on Kotlin. Now everything is crystal clear. Amazing video!
Hey John, thank for the tut! You made generics so simple to understand. Would love to see tuts on followings;
Method referencing,
Lambda Functions
Optionals
Stream API
Thanks again.
Totally, Lambda is really confusing
@@flex_prods no it isnt
That's the most simplest part of java 8 😃
i learnt everthing on generic in 17 minutes.... thank you John.. great video content..
Only if our university was this chill to teach something simply like you do. They start with complicated stuff and it gets nowhere in our heads. Thanks for the Tutorials.
I've been working with Java for 16 years but I still watch your videos since they are satisfying
What is the difference between List and List ?
I am literally afraid of generics in java. Could never understand what are T, V & ? . But your video made me understand the basics so clear. Thank you so much !!
I'm watching this video every time that I come across generic types in my work, Man, you are a great toter thanks a lot...
I wish my intermediate Java programming class was just your videos imbedded with the labs and questions I would fly through it. Thank you
This is the greatest Java tutorial I have ever found on TH-cam. Not too lengthy, covered huge concepts within a few minutes. As well as clear and understandable English.
Thanks.😍
I'm here because a paid trainer didn't managed to make me understand the Generics. Now it's more clear to me. Thank you, kind sir!
I am a beginner in Java and even though I don't know that much about Java I could easily understand most of the things in the video. I'm so happy that I came across your channel. Looks like this channel will help me a lot :D
I love how you ask yourself why we should use this and explaining very clear
Thanks!
I actually studied this extensively so many years ago and ended up implementing it for the DAOs used by the ORM in one of the projects I was assigned in in my previous company. To this day, I hear they are still using it as some sort of framework code for DAOs used by ORMs in that company even when I'm no longer around there.
Watching this video reinforces the things I have learned and made me more confident that the things I learned when I studied it alone were correct. Kinda makes me feel that although it was an overextension of effort, it wasn't in vain.
So in your code you have :
private static void PrintList (List myList) {}
Couldn't you also do ??:
private static void PrintList (List myList) {}
They appear as though they work the same, so what's the difference, surely one is better than the other (or more dangerous to use if the compiler doesn't treat it the way we want) ?
This is the best video on generics. And I’ve seen nearly all videos on generics on TH-cam.
Great crash course on Java generics. Each time during the video I was like "What about this situation", you covered it shortly after, which was great. Thanks.
The way you explain with coding examples showing how they work.. that too in a simple way is amazing.
Very Helpful! Clear concise and complete explanation. If someone is finding it a little fast please slowdown the playback speed and watch the video, it's really good.
Great video, thank you for the explanation! Tho I haven't noticed any info about why not to use generics everywhere. Googled a bit and found this:
The only case when wildcards is the only option:
Wildcards support both upper and lower bounds, type parameters just support upper bounds. So, if you want to define a method that takes a List of type Integer or it's super class, you can do:
public void print(List
Hey man, I just want to say thank you. I've been struggling with this topic for a while now and now I feel a lot more comfortable working with generics after watching this video. You're the best!
One doubt: when you spoke about wildcards, you gave the example of passing a List of any class to a method. Instead of using wild card, we could've used this way right?:
private static void printList(List myList)
This works perfectly fine as well, then why do we need wildcards ?? 🤔
I have the same doubt. anyone could explain, please?
I went through a 3 hour lecture on OOPs and after that went through a couple of TH-cam videos but I was not able to fully understand what exactly generics were and why are they used. Then I came across this 17 minute video which cleared all my doubts and made everything super super simple. The difference a teacher makes is unbelievable. Subscribing and watching other videos too. Thank you so much!
This is the actually the best explanation o generic types ever, not only for Java but the concept as a whole!
I never understood this topic for years , I am having my interview tmrw this helped me a lot to understand it quickly.KEEP DOING THE GOOD WORK MAN !!!!❤
I did mountains of Java from mid-90's to 2010-ish, then focused on an architect role. I recently had to understand a new Java framework and it uses all these new Java features - I was having a hard time scanning through the code. THANK YOU for the clear and concise explanation.
thanks, defining generics was on an exam, and you gave me the answer before the 5 minute mark!
What'd be the difference between: "private static void printList(List myList)" and "private static void printList(List myList)"??
Wow! fast but best explanation ever, good job.
Fantastic video. The "why" in the beginning is what really solidified my understanding as to why we need generics.
I know how to use generics, but now I understand why we really need them! Thank you!
This is hands down one of the best Java channels and video tutorials I have seen available on TH-cam! Earned a sub!
Thank You So Much....
Finally Even After 2 Years Of Professional Experience Got To Know Generics Clearly....
Thanks A Lot....
I finally understand Generics. Fourth time i go through this topic. THANKS!!!!!!
I used to hate java, till i discovered this chanel, thanks a lot
You Deserve Noble prize for crystal clear explanation which I don't understand over the years ......tq .
This is no longer super confusing, best tutorial I've seen on the subject, thank you John!
best java generic video I've eve seen
I swear, without you and your videos I would not be passing my Advanced Java class this semester. Thank you so much!!!
Honestly I have learn many things about generics in this small video. Thank you John for such a nice explanation and hands on demo on generics.
John, you are just a gifted teacher. Thank you so much for these videos. I've reached the age that I can never remember all the Java stuff I've learned, and I know I can get a quick refresher that will have me back up to speed by watching one of your videos. Or if I need to learn a new topic, I can just watch one of your videos and in a short time I'll be up to speed. Thank you so much.
You really know how to teach and get knowledge across. Some people are knowledgeable but don't know how to teach. I learn a lot from your videos. Thanks a lot.
Thank you so much for making your videos. I have problems with concentration of attention and memory, and it is difficult for me to listen, watch and read something for more than an hour. I am now in my first year at university and your videos help me so much to understand the material better and remember it for a long time.
Wow no words. Hands down the best Explanation of Generics🥰
First and foremost, I would like to thank you for your excellent teaching. I have been learning this topic for months, and now I have fully understood it. I would recommend providing the code used in the lessons as a zip file.
Thanks for clarifying the usage of each. I was mostly confused about ?, but it now makes sense that its used with collections rather than individual objects.
What's the difference between:
private static void printList(List myList)
and
private static void printList(List myList)
I learnt everything in just 17 min as compared to my 2 hr lecture. Thanks!
Man, you make me want to binge watch the entire java playlist in one sitting.
I have learned two thins today that had plagued me for years ! 1. The and 2 the reason that the list is not subclass of list
you literally made Java so much easier for us......super job
I failed an interview. One question is about Java generic which was introduced in 1.5. I never wanted to review it with details since I thought I knew it when I used the similar feature in C++ years back. It turns out I needed to. This video really helps in a sense covering pretty much every corner of this feature in an easy to understand way.
I have seen many of your videos. You are by far, the best Java content creator.
Thanks! By far the Best video on Java Generics! Have a coffee on me!
Much thanks!
Hey John, thanks for the video, it's very informative.
I got a question about the code in the video at 16:05. Why should I use and not in the example ?
I'm just quoting the video, from memory "...although Integer is a subclass of Object, List isn't a subclass of List..." Better watch it again. I had to :)
dude you are the best java teacher on youtube. thank you
Such an excellent explanation of Generics. Before coming to this video, I was reading Head first Java and couldnt understand the Generics properly. Then I encountered your video and by the time I completed I have understood it clearly. Thank you for your passion . You are an amazing teacher. Good Day!
Glad it helped, thanks for watching!