Also, something else to add about generics: If you’re expecting some specific property of the class you put into a generic, you can write that into your generic. For example, if your class had an array of T’s that you wanted to sort, just putting MyClass will make your compiler complain that you’re doing something unsafe. This is because you can only use sort() on the array if the class T implements the Comparable interface and its compareTo() method, and there’s no guarantee someone won’t try to make it with some class Java doesn’t know how to compare or sort (like a custom one). The solution here? Write your class header as MyClass. This tells the compiler that you will only make MyClass’es with types that can be sorted. This uses “extends” as opposed to the “implements” usually used for interfaces because you’re just making a promise about the generic class, not actually implementing one, and the second T is because Comparable is also generic (so you need to say that T implements a method to compare T objects specifically).
@@KnakuanaRka "For example, if your class had an array of T’s that you wanted to sort, just putting MyClass will make your compiler complain that you’re doing something unsafe"
@@KnakuanaRka What is reification in Java? In the context of Java as a programming language, reification is the process by which a user program or any aspect of a programming language that was implicit in the translated program and the run-time system, are expressed in the language itself. In Java, there exist "reifiable types" that are "completely available at run time" (i.e. their information is not erased during compilation). Example: //Allocates an array of type String, so it is reified String[] aStringArray = new String[10]; //Allocates a list with no type, Java does not reify generic types List aStringList = new ArrayList();
This is the best explanation of Generics I've seen on the internet. I loved how you started with the problem to solve, and then showed how generics is useful when tackling that problem :)
I like the way you explain things: Java developers created Generics to solve a problem, so I think its pretty logical to talk about the problem before talking about the concepts that were created to solve it. Great video !
I just watched 9 hours of online classes from my teacher on generics and I understood nothing. Less than nothing. 10 minutes of you and everything is clear it's super easy actually.
Thank you so much, Sir. You made the explanation for generics very simplified, especially, by the style of starting with the problem first and then showing the solution! 🤩
Lounge Coding! I really liked the theme. A new touch to coding tutorials. I am your fan now. You rock! Oh! And the stuff that you covered in this tutorial is of great value. You explained it easily and flawlessly.
This just might be personal preference but the best and most detailed explanations for anyone studying comp sci are found in this channel - no idea why views haven't hit a million
Probably topics like interfaces, polymorphism, exceptions, collection frameworks etc. There's a huge Quora thread that might help you as well: www.quora.com/What-is-a-complete-list-of-topics-of-Core-Java-and-topics-of-Advanced-Java
Yes, in my latest Java project. While they seem easy in theory, implementing them is another matter! I hope to gain knowledge from this video and other sources and thus strengthening my performance in this area.
This looks like it's from java, a beginner's guide. I too was confused on what generics fix but thank you for explaining it in the beginning of the video. I think you should do that to all your videos
Not sure why it's still taking me a minute to wrap my head around Generics. I'm sure it'll click, but it's so funky to me even with your great explanation.
Watched 2 videos, had it at uni, read documentation and still didn't understand why Wildcards are useful. You basically explained it in 2min with a simple example. Thank you very much.
Dope! I am currently in an Intermediate Programming college course and they just want us to read a document. I was so lost. This clarified alot. Also it cause me to switch from Netbeans to IntelliJ IDEA hahaha
Ah, another example of my previous compsci professors failing to teach something fairly straightforward... *facepalm* You, on the other hand, taught it in such a practical and applicable manner: Discuss a simple problem and then propose a solution (and actually working through the example) Super easy to remember too. Great video!
You can also declare generic type at method scope id you're planning to use static methods (methods that are not requiring you to instantiate class to use it)
You didn't cover generic methods and the parameter type lists before the returned type in a method definition. I've been using generics for years and just learned this today! Don't have to use this when you're just a consumer of generic classes.
☕Want to master Java? Get my complete Java course: bit.ly/42mQlXE
Also, something else to add about generics:
If you’re expecting some specific property of the class you put into a generic, you can write that into your generic. For example, if your class had an array of T’s that you wanted to sort, just putting MyClass will make your compiler complain that you’re doing something unsafe.
This is because you can only use sort() on the array if the class T implements the Comparable interface and its compareTo() method, and there’s no guarantee someone won’t try to make it with some class Java doesn’t know how to compare or sort (like a custom one).
The solution here? Write your class header as MyClass. This tells the compiler that you will only make MyClass’es with types that can be sorted. This uses “extends” as opposed to the “implements” usually used for interfaces because you’re just making a promise about the generic class, not actually implementing one, and the second T is because Comparable is also generic (so you need to say that T implements a method to compare T objects specifically).
It's not because of reification of arrays?
@@eustachybakielka Not sure what you’re referring to.
@@KnakuanaRka "For example, if your class had an array of T’s that you wanted to sort, just putting MyClass will make your compiler complain that you’re doing something unsafe"
@@eustachybakielka What the heck is reification of arrays?
@@KnakuanaRka What is reification in Java?
In the context of Java as a programming language, reification is the process by which a user program or any aspect of a programming language that was implicit in the translated program and the run-time system, are expressed in the language itself. In Java, there exist "reifiable types" that are "completely available at run time" (i.e. their information is not erased during compilation).
Example:
//Allocates an array of type String, so it is reified
String[] aStringArray = new String[10];
//Allocates a list with no type, Java does not reify generic types
List aStringList = new ArrayList();
This is the best explanation of Generics I've seen on the internet. I loved how you started with the problem to solve, and then showed how generics is useful when tackling that problem :)
true dat. Fell the same
True
I like the way you explain things: Java developers created Generics to solve a problem, so I think its pretty logical to talk about the problem before talking about the concepts that were created to solve it. Great video !
Super great point(illustrate the problem to solve, before the concept). A lot of Java Channels should be taking notes!!
Totally agree - it's hard to get excited about a key if you haven't seen the lock that it opens
Keep On Making such videos on Keep On Coding channel. Really Helpful !!
Thanks for watching Deepti!
Dude thank you. My text book way over complicated generics. Now it all makes sense.
that was really simple i love the way you edit the video making switch between you and the code it feels so clean, thank you
I like this fast paced explanation.
You're incredible you explained with 12min a concept that my professor couldn't do it with 1 hour. Keep doing this amazing job thank you so much!
Second year of studying Software Development in Uni and this is just the best explanation ive heard! Great job man!
Finally understood generics, thank you so much!.
I just watched 9 hours of online classes from my teacher on generics and I understood nothing. Less than nothing. 10 minutes of you and everything is clear it's super easy actually.
yeah not every professional or teacher is able to share his knowledge the proper way... ;)
@@technocoh yeah if someone need 9 hours to explain a concept you can safely assume they are the first who don't understand it
Thank you so much, Sir. You made the explanation for generics very simplified, especially, by the style of starting with the problem first and then showing the solution! 🤩
This is the most concise and easy to understand video I've seen so far on Generics, thank you so much :D
Possibly one of the best, clearest, and crispest explanations on the generic class that I've seen! Keep up the great content dude!
i highly agree with you, the guy is so clear with his explanations
bro your java playlist is so underrated. I love it
Man, thank you so much, i finally understand those generics now :D
awesome stuff. I liked the way you explained it - showing the problem first and how generics can help save the day!
This video really helped me understand Generics way more than my instructors classes
Lounge Coding! I really liked the theme. A new touch to coding tutorials. I am your fan now. You rock! Oh! And the stuff that you covered in this tutorial is of great value. You explained it easily and flawlessly.
I read a thirty page chapter on this, one ear out the other. This video is outstanding, mind blown.
Why can't everything be explained this clearly and quickly?
Thanks for doing this and keep up the good work.
Wow! You explained it all so good. I finally feel like I understand this. Thank you so much. Please keep it coming.
Thank you so much for this! I love your Java tutorials. So simple, clean and explanatory. Keep up the good work!
You seem like just a solid dude haha thanks for the help man!
This just might be personal preference but the best and most detailed explanations for anyone studying comp sci are found in this channel - no idea why views haven't hit a million
This is legit the best video I could find to understand Generics!
Thanks for the video mate. Pretty well explained.
Would be awesome if you keep making videos about core and advanced OOP concepts like this.
Thank you sir. Did you have a specific topic in mind?
Probably topics like interfaces, polymorphism, exceptions, collection frameworks etc.
There's a huge Quora thread that might help you as well:
www.quora.com/What-is-a-complete-list-of-topics-of-Core-Java-and-topics-of-Advanced-Java
Awesome! Thanks!
This was such a great explanation of Generics. I've been so confused about it for the past few weeks. Thank you!!
what a good, easy, and elegant way to explain generics ... keep it up!!
This tutorial is helpful for filling the gaps in generics, thanks for explaining thoroughly.
Thank you so much! Please, keep doing videos like this!
Thank you for this quick video. You saved me 30 minutes of reading long paragraphs from my lecturers.
Have you ever used Generics in your code?
nope
yea! coming from c++, i was taught that its called templates
Yup. My Data Structures professor would always require us to use them. Still don’t understand them. Hopefully this video will help me understand!
Yes, in my latest Java project. While they seem easy in theory, implementing them is another matter! I hope to gain knowledge from this video and other sources and thus strengthening my performance in this area.
Keep On Coding Yee for my assigment
This looks like it's from java, a beginner's guide. I too was confused on what generics fix but thank you for explaining it in the beginning of the video. I think you should do that to all your videos
Nice and simplified explanation of a complicated topic. Thank you.
This was the best explanation on youtube, short and concise. Thank you and keep making such videos
I was struggeling with understanding generics until I watched your video. Thanks a lot :)
Thank You very much .. after looking many videos from different sources ....... this video absolutely cleared my thoughts for Java Generics.
Nice video! Very easy to understand explanation of the concept.
Thankyou so much. You're very talented in explaining complicated Java thingys!
Not sure why it's still taking me a minute to wrap my head around Generics. I'm sure it'll click, but it's so funky to me even with your great explanation.
Wow this is one of the best explainer videos. Loved watching it🤩
Great video man, keep doing what you do
Watched 2 videos, had it at uni, read documentation and still didn't understand why Wildcards are useful. You basically explained it in 2min with a simple example. Thank you very much.
very nice to the point video, subbed
Exceptional video, very clear!
Man this was a fantastic explanation
I particularly liked how you first showed what the problem was then showed how generics solve it
Keep on man, cool teaching style
Very well! Nice explanation of usages of Generic types, and Wildcards.👌(helps in understanding the difference between them and their significance)
Dope! I am currently in an Intermediate Programming college course and they just want us to read a document. I was so lost. This clarified alot. Also it cause me to switch from Netbeans to IntelliJ IDEA hahaha
Yes, this is the best one I found. Thanks!
10/10 man! Keep it up. It's better than my current professor!
Lol glad it helped!
Your videos are very helpful and your teaching methods are very clear
Excellent quality! Thank you
Seriously this way of learning from the problem is amazing! Thanks Sir!!
Very informative and loved your communication style
Awesome explanation, thanks for your help!
I love teaching to the problem. Great video and thanks!
I'm spanish speaker, your videos are sooo good than I can understand, thank you
Ah, another example of my previous compsci professors failing to teach something fairly straightforward... *facepalm*
You, on the other hand, taught it in such a practical and applicable manner: Discuss a simple problem and then propose a solution (and actually working through the example)
Super easy to remember too. Great video!
Very well explanation and approach
Thank you for creating this video! Very concise and informative
That was lit bro!!!! Thanks for crystal clear explanation :))))
I understood the topic very well.Thank you so much Please share more videos
Great video! Detailed and to the point.
Nice video. You do have a great way of explaining things.
You can also declare generic type at method scope id you're planning to use static methods (methods that are not requiring you to instantiate class to use it)
Learned hella! Good looks my guy
Great explanation - clear and helpful. Thank you.
correction: you should make this function type-bounded as well, like this --> "boolean absEqual(NumericFns
Explanation clear and concise thank you
Great work keep it up
Great and simple explanation, I like this way of teaching a lot.
Sweet tutorial, just subscribed
WOW' You're good at teaching code and concepts. Way to go!
really well explained m8. Appreciate it. thx
Thank you, It was very helpful as usual.
it's really helpful,thanks a lot .
Subscribing man. You helped so much.
Awesome explaination, thank you!
Best tutorial! Thanks for your explanation!
Thank you, I learnt something new today
Great explanation! Just gained a new Sub. Thank you and keep it up please!
I know what generics are but I still feel I learnt a few new things here. God Dayummm you are awesome.
You look like you're gonna fall asleep the next second, but you explained the topic very well!
Holy shit THANKS!
i like the u develop the subject, uake java very easy to work with
That was a great explanation of Generics, keep up the good work, I just subscribed to your channel. Do you have something on Java annotations?
Great explanation KOC!
Clean, simple and perfect content!
Thank you, excellent explanation!
MAAAAAAAAAAAAAAAAAN that was just awesome thank you very much!
You didn't cover generic methods and the parameter type lists before the returned type in a method definition. I've been using generics for years and just learned this today! Don't have to use this when you're just a consumer of generic classes.
well thank you for explaining to me what i didn't learn from the class.
Awesome tutorial bro
Really awesome bro!
You are awesome bro, thank you for this video
You are awesome! thank you good sir
perfect. That deserves a thumbs up.