Java Generics Tutorial

preview_player
Показать описание

#keeponcoding #tech #programming
Рекомендации по теме
Комментарии
Автор

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<T> 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<T extends Comparable<T>>. 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
Автор

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 :)

lindawisebear
Автор

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 !

philippebaillargeon
Автор

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

abdullahmajed
Автор

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!

IgorBeneli
Автор

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.

delmayank
Автор

This is the most concise and easy to understand video I've seen so far on Generics, thank you so much :D

JosephGallagher
Автор

Dude thank you. My text book way over complicated generics. Now it all makes sense.

TS-wjim
Автор

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! 🤩

mohannadfadhal
Автор

Thank you so much for this! I love your Java tutorials. So simple, clean and explanatory. Keep up the good work!

fredericoamigo
Автор

Second year of studying Software Development in Uni and this is just the best explanation ive heard! Great job man!

shagiwan
Автор

This was such a great explanation of Generics. I've been so confused about it for the past few weeks. Thank you!!

hannahc
Автор

Keep On Making such videos on Keep On Coding channel. Really Helpful !!

deeptimonga
Автор

This was the best explanation on youtube, short and concise. Thank you and keep making such videos

shreypatel
Автор

Wow! You explained it all so good. I finally feel like I understand this. Thank you so much. Please keep it coming.

Автор

awesome stuff. I liked the way you explained it - showing the problem first and how generics can help save the day!

philyeo
Автор

Great video man, keep doing what you do

CarlosRamirez-uzhs
Автор

Man, thank you so much, i finally understand those generics now :D

BoetFly
Автор

Thank you so much! Please, keep doing videos like this!

isah.
Автор

This is legit the best video I could find to understand Generics!

gauravkumarsingh