Тёмный

Generics in Java 

Telusko
Подписаться 2,4 млн
Просмотров 504 тыс.
50% 1

Check out our courses:
Spring and Microservices Weekend Live Batch : bit.ly/spring-live-weekend
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : bit.ly/java-spring-cloud
For More Queries WhatsApp or Call on : +919008963671
website : courses.telusko.com/
Instagram : / navinreddyofficial
Linkedin : / navinreddy20
TELUSKO Android App : bit.ly/TeluskoApp
Discord : / discord
In a nutshell, generics enable types (classes and interfaces) to be parameters when defining classes, interfaces and methods.
Much like the more familiar formal parameters used in method declarations, type parameters provide a way for you to re-use the same code with different inputs.
The difference is that the inputs to formal parameters are values, while the inputs to type parameters are types.
Code that uses generics has many benefits over non-generic code:
- Stronger type checks at compile time.
A Java compiler applies strong type checking to generic code and issues errors if the code violates type safety.
Fixing compile-time errors is easier than fixing runtime errors, which can be difficult to find.
- Elimination of casts.
- Enabling programmers to implement generic algorithms.
By using generics, programmers can implement generic algorithms that work on collections of different types, can be customized, and are type safe and easier to read.
In this video we will see :
- What is Generics
- What is Type-safe Language
- How to achieve type safety
- An example or program of Generics implementation in Java
Java and Spring Framework For beginners with Spring Boot : - bit.ly/3LDMj8D
Java Tutorial for Beginners (2023) :- bit.ly/3yARVbN
Subscribe to our other channel:
Navin Reddy : / @navinreddy
Telusko Hindi :
/ @teluskohindi

Опубликовано:

 

1 дек 2016

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 166   
@arkojyotisen1929
@arkojyotisen1929 4 года назад
Sir in this lockdown I have learned a lot in programming just because of you. Thank you so much
@queenskeleton4937
@queenskeleton4937 5 лет назад
Best Java channel. Straightforward explanation, with code live demonstrated. You are sure to learn just by watching this. I learned from you in Spring Boot, REST services, and Java core APIs. Thank you so much!
@vikashemnani2371
@vikashemnani2371 3 года назад
Telesko is good but I would like you to check Java Brains channel of Kaushik, your view might change
@anthonycarella1779
@anthonycarella1779 5 лет назад
Very straight-forward and easy to understand. Thanks for the content!
@nasreenmohsin
@nasreenmohsin 6 лет назад
he explained it in very simple manner now i understand this concept hope he will upload more complex way to define generic
@willyang1770
@willyang1770 2 года назад
Thank you so much! I've been looking all over the internet for this and none of them were as good and straightforward as this! Thank You SO MUCH!
@Aryan46KingOfHearts
@Aryan46KingOfHearts 4 года назад
sir how to do that you have done at 10:49 to see which class/interface extends which class when i do that in eclipse by holding control something different shows up "source not found "
@crankMiHoffer
@crankMiHoffer 5 лет назад
7:35 mind blown; thank you for this video
@MsElsospechoso28
@MsElsospechoso28 4 года назад
This guy is awesome, he really likes teaching which is highly appreciate it.
@madanpatel797
@madanpatel797 5 лет назад
Hi Telusko, Could you please tell us how to access the java provided classes like List.class and Float.class. I use Eclipse as well but haven't figured it out yet. While doing so I am getting the following error: The JAR file C:\Program File\Java\jre1.8.0_201\lib t.jar has no source attachment.
@divyeshkumarbalar7732
@divyeshkumarbalar7732 6 лет назад
your title music is damn scary if you have seen haunted on discovery channel
@wisniewz
@wisniewz 4 года назад
Read this as I was thinking the same thing. I'm dying over hear with that into music. LOL
@cori2852
@cori2852 4 года назад
as scary as generics in java
@mainakray6452
@mainakray6452 3 года назад
​@@cori2852 :))))))
@fanwu281
@fanwu281 5 лет назад
Thank you so much, it's very easy to understand!
@aishwaryadash4166
@aishwaryadash4166 3 года назад
This is the single most important video if you want to be clear about Generics...Thank you!!
@nicksonmakama
@nicksonmakama 5 лет назад
This really is the best video on Generics, I love it!
@divyeshkumarbalar7732
@divyeshkumarbalar7732 5 лет назад
I dont know why, but i am not being able to jump to implementation of any java inbuilt classes? Any help!
@schemerboy1005
@schemerboy1005 5 лет назад
What if I want to use everything related to T (aka, both the supers and subclasses of T and also T itself?)
@alisu111
@alisu111 5 лет назад
Great video, now I understand the concept. Thanks a lot!
@gajeshtripathi5721
@gajeshtripathi5721 3 года назад
I was always confused with "? extends ..." & "? super ...." but now it is clear to me. Thanks Navin Sir.
@mohitsinghrawat503
@mohitsinghrawat503 6 лет назад
Awesome bro... Best Video I ever saw for Generics... Thanx man.
@zhongweimao5548
@zhongweimao5548 4 года назад
Thank you so much Bro for your explanation. Your video resolved many of my confusion that even my lecturer was not able to solve coz she did not understand my confusion. Generics is much more clear now for me.
@nasreenmohsin
@nasreenmohsin 6 лет назад
need help confusion on following declaration why .. 1) class CalendarDate implements Comparable (when we implement Comparable we write in the end ) 2) class OrderPair implements Pair .... (in user define interface we write after Class can somebody explain it)
@romeoacevedo1040
@romeoacevedo1040 4 года назад
Really nice explaination. Thanks for all the details!
@abhishekedu
@abhishekedu 4 года назад
The beauty of java is that before solving clients problem you have to solve java problems.
@2wardruid2
@2wardruid2 4 года назад
Thank You, your lesson helped me a lot!
@dipagove8963
@dipagove8963 5 лет назад
Thanks lot... for exact concept of java & all telusko videos to teach all technologies
@farhaankazi7134
@farhaankazi7134 Год назад
in method definition of public void demo(ArrayList
@kiranvysya
@kiranvysya 2 года назад
I knew about Telusko from its inception but never liked or followed. But after seeing this one single lecture. Hands down never judge a book by its cover
@vladanulardzic5859
@vladanulardzic5859 4 года назад
100% explained ! Knowledge necessary for heavy solutions. Thank you. Keep on.
@i.d.1988
@i.d.1988 6 лет назад
Another great video that helped me with understanding my school homework. Thank you sir.
@alexandernaywin8250
@alexandernaywin8250 3 года назад
Thank you so much, your generics explanation is awesome.
@manikandand2541
@manikandand2541 4 года назад
u have some enormous talent sir...plz continue this job..all the best
@abhinavgupta3387
@abhinavgupta3387 4 года назад
Good leason. I was easily able to understand the generics. Thanks.
@mrrobot1289
@mrrobot1289 3 года назад
Very detailed explanation. THANK YOU!!!!
@Layarion
@Layarion 2 года назад
Now this was a good video. You didn't cut it too short and leave out some of the nuances like others do. Now i'ma go lookup that ? thing and Super.
@ashuzguitar
@ashuzguitar 2 года назад
Thanks a ton Navin. You are the best!
@govardhangova5411
@govardhangova5411 2 года назад
sir in Hash map can we enter only key and values or we can enter one key no of values (like = sid,sname,address and phone )
@govindrudrawar2540
@govindrudrawar2540 4 года назад
lucid explanation. I have been watching ur videos for quite a while now. Thanks Navin Reddy. ur amazing.
@nagendrasai3946
@nagendrasai3946 6 лет назад
Well explained. Thank you very much
@aminesfahani3563
@aminesfahani3563 3 года назад
The best explanation for Generics and Collection interface and Collections classes
@blablablahh612
@blablablahh612 5 лет назад
what if I want to use student class eg: Container obj=new Container(); how will i write my student class then? i am confused
@contactamartya
@contactamartya 6 лет назад
many many thanks ... superb video
@karanhaldar3401
@karanhaldar3401 11 месяцев назад
I can't understand this in my class but here I've cleared all of my confusions in one shot ❤❤❤❤ Thank u sir ❤❤
@sourabhbagade6932
@sourabhbagade6932 4 года назад
Even I m non it student, I m getting this concept clearly Thanks to telusko🙏👍
@aaratprasadchopra3255
@aaratprasadchopra3255 3 года назад
Thank You Navin, BIG Help!
@SanjayKmsd
@SanjayKmsd 6 лет назад
You are simply awesome Navin
@Fnaf-vh9cs
@Fnaf-vh9cs 3 года назад
This man is great I wish you a healthy and happy life and thanks for sharing.
@ShujathHussain0
@ShujathHussain0 6 лет назад
why LIST interface methods are not asked to be implemented? rather its optional but when we create a new interface and add some methods, they need to be used mandatorily.
@thomasflood8507
@thomasflood8507 6 лет назад
Excellent!! Thank you very much indeed. .
@studyonline3236
@studyonline3236 4 года назад
Hello anna! just want to know about something which I encountered while I was coding my own Collections(say linkedList). So, I used and everything was working fine, however, when I tried to write a method for finding minimum in Linkedlist, compiler keeps throwing errors(as finding minimum wouldn't be possible if the type were (T=)String. So, I want just this method to accept Integer or any Number values and whenever the type doesn't fit it should neglect it. How can I do so?
@jvsnyc
@jvsnyc 3 года назад
@Ankit5311
@Ankit5311 5 лет назад
Its similar to temlate in C++. They changed template to generics
@yonis963
@yonis963 5 лет назад
clear explanation , thanks mate.
@TsukiCTF
@TsukiCTF 7 лет назад
Just asking, but what is the point of adding getters and setters in the class Container? From what I have tested so far, everything worked fine without those..
@djus5
@djus5 6 лет назад
Everything worked fine without those because getter and setter for value were not used/called anywhere in the code. Point for adding those was just to show how generics works. For example, if you made object obj, like in the video: Container obj = new Container(); and you want to set value for it: obj.setValue("Java"); then compiler will know that T is String, public void setValue(T value); ----> public void setValue(String value);
@shrutikanachankar4932
@shrutikanachankar4932 Год назад
Thank You Sir🙏🏻. You taught it very well .
@shwetarautr01
@shwetarautr01 4 года назад
Hello sir! I need to know which subclass is sorted hashMap Or hashTable... ??? In case of.... Map m= new HashMap(); or HashTable() ;
@PatteeGreen
@PatteeGreen 2 года назад
Thank you!! Excellent explanation :)
@am-oo5uu
@am-oo5uu 5 лет назад
Great video. Thank you so much. Could you tell me how to access the java proviced classes like List.class and Float.class. I use Eclipse as well but haven't figured it out yet.
@JimmyBFMV
@JimmyBFMV 5 лет назад
Do you mean: How do you go to the implementation of List? Just right click --> Go To --> Implementation (or [Ctrl]+[Alt]+[B]).
@fluffy24
@fluffy24 2 года назад
You are really great my friend, tank you for your videos
@A09550
@A09550 7 лет назад
concise and clear, thanks
@thatsenam9183
@thatsenam9183 6 лет назад
such a awesome video. I loved it.
@mr.RAND5584
@mr.RAND5584 4 года назад
Entities have different type of class. Student class, employee class. Thanks i need to populate data from database as List
@vineethnair4137
@vineethnair4137 4 года назад
Naveen sir your presentation is simple and understandable
@intsoumen
@intsoumen 7 лет назад
Awesome Video I have ever seen , in short in 5 min Complete Compaq
@muhammadmoersalin6846
@muhammadmoersalin6846 5 лет назад
great explanation, thanks.
@sreenivasa233
@sreenivasa233 6 лет назад
Hello Sir, Thanks for videos really very nice. I tried to check same code in my exclipse ide but I am getting an error when super keyword is used with Number and when passed Integer to ArrayList /* Code start here */ import java.util.ArrayList; import java.util.List; class Test{ public static void main(String args[]){ Container obj =new Container(); obj.value=9; obj.show(); obj.demo(new ArrayList()); //Getting error here but as per your lecture this will not happen } } class Container{ T value; public void show(){ System.out.println(value.getClass().getName()); } public void demo(ArrayList
@TheCodeHunter
@TheCodeHunter 3 года назад
thank you so much for this!
@akchatsrivastava4209
@akchatsrivastava4209 6 лет назад
Great method of teaching.
@thehiddenbalkans
@thehiddenbalkans 3 года назад
Love the way you say "Dabl" & "GettaSetta" :D
@adityamishra2044
@adityamishra2044 3 года назад
9:05 when he laughed?
@sergdv3863
@sergdv3863 6 лет назад
Can you show a real example of using super keyword? I understood that it is used as constraint for concrete type, but when and where I should use it?
@djus5
@djus5 6 лет назад
Use '? super T‘ whenever you want to indicate a type which is a super-type of 'T'.
@hiteshchalise3988
@hiteshchalise3988 5 лет назад
This helped, thanks :)
@pranaytanniru7764
@pranaytanniru7764 4 года назад
It's clear, thank you.
@-indeed8285
@-indeed8285 6 лет назад
BEST ever
@tuweiIsaac
@tuweiIsaac 4 года назад
its good that such people do exist.#ilovetelusko
@milad_mo
@milad_mo 3 года назад
It was good but please discuss about generic method and uses of generics in combination with reflection
@blockbuster8101
@blockbuster8101 6 лет назад
It showing an output is true is type is matching other wise showing an error what we can do to print a exact values
@studyonline3236
@studyonline3236 4 года назад
what's T extends Comparable ?
@Isha_Sethi
@Isha_Sethi 3 года назад
4:12 I didn't understand line 18...what is it doing? 13:05 didn't understand
@ekramamazhar6282
@ekramamazhar6282 3 года назад
how to get rid of Raw class warning without suppressing it.
@blablablahh612
@blablablahh612 5 лет назад
excellent video!!!!
@RohitKumar-wq9lk
@RohitKumar-wq9lk 11 месяцев назад
Bhai Mere mazza aa gya yaar
@guambomber448
@guambomber448 3 года назад
WOW that was a great video!
@madanmohanpachouly6135
@madanmohanpachouly6135 2 года назад
Well Explained
@chakibbensari1850
@chakibbensari1850 3 года назад
The error at 3:37 is about Integer.parse() and not the List.add
@harshitahuja5043
@harshitahuja5043 2 года назад
Excellent Video
@ayushchhanganni2357
@ayushchhanganni2357 2 года назад
Amazing content!!
@mehrshadtavana1429
@mehrshadtavana1429 3 года назад
very helpful tnx a lot
@berjaoui92
@berjaoui92 5 лет назад
I would like to donate but i want to use my paypal. is it possible ?
@ahsanali5527
@ahsanali5527 3 года назад
great explanation
@ashokchilakala2879
@ashokchilakala2879 3 года назад
sir will u please provide the practical session videos
@nethrajoshi1593
@nethrajoshi1593 3 года назад
CAN WE USE ? WHILE CREATING GENERIC CLASSES
@atulaggarwal2897
@atulaggarwal2897 2 года назад
Why can't we use T or K or anything in place of '?'.
@lemaaaron9009
@lemaaaron9009 Год назад
Thanks I love it 🤝
@mohammadsulthan9379
@mohammadsulthan9379 3 года назад
Sir you showing list.class but how to go it sit
@foton8998
@foton8998 4 года назад
thank you. It was effective
@admannas123
@admannas123 3 года назад
Nice explanation
@digitalnomadg
@digitalnomadg 6 лет назад
Sir what was that - value.getClass().getName() ????
@djus5
@djus5 6 лет назад
class Container can take any type as parameter (T), when you are creating an object of class Container you can specify which type inside , for example: Container obj = new Container(9); Container obj1 = new Container("Java"); next, in Container class we have show() method when we call that method on obj or obj1 it will return type of obj and obj1 by using getClass().getName() try it in your IDE, type value press . and see list of methods you can use docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass-- docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getName--
@Ren-nf4pz
@Ren-nf4pz 3 года назад
very good thanks
@neerajvas
@neerajvas 7 лет назад
Excellent!!!!!
4 года назад
Nice vid man!
@user-lb1fl7sh8m
@user-lb1fl7sh8m 7 лет назад
what is the differenes of list< T > with list< ? > ?
@divyeshkumarbalar7732
@divyeshkumarbalar7732 6 лет назад
list -> where T can be any fixed type and which is entered by you as a programmer and than it can not be changes in the middle list -> this is wild card, which can be anything. usually used when you dont know whats going to come up
@3yogimaggi
@3yogimaggi 5 лет назад
value.getclass().getname () . what does it do ? didn't get it
@loizosloizou2907
@loizosloizou2907 5 лет назад
It returns you the name of the objects class.
@nynra6584
@nynra6584 7 лет назад
Thank you for this well made explanation
Далее
14.2 Collection and Generics in Java |  Practical
14:33
Просмотров 290 тыс.
Stream API in Java
26:04
Просмотров 296 тыс.
Java generics ❓
22:04
Просмотров 104 тыс.
Java Generics Tutorial
12:23
Просмотров 180 тыс.
Interview Question | Comparable vs Comparator in Java
12:58
Generics In Java - Full Simple Tutorial
17:34
Просмотров 1 млн
Learn TypeScript Generics In 13 Minutes
12:52
Просмотров 245 тыс.
Generics in Java - Full Tutorial
20:08
Просмотров 27 тыс.