Premium Only Content
Java Generics
Java Generics enable us to gain type safety in situations where classes and methods that are designed to be able to work with any type would otherwise be designed to work with Object instances. For instance, without Java Generics the Java List, Java Set, Java Map etc. interfaces would all be working on Object instances. With Java Generics you can create List, Set or Map instances that work on specific types, e.g. a List of Strings, rather than a List of Objects, so you achieve a higher type safety in your code.
Java Generics add type parameters to classes, interfaces, methods and variables that decide to use them. To be able to use a type parameter with a class, interface, method or variable the type you are trying to add the type parameter to, must be designed to allow generic type parameters.
Many of Java's built-in utility classes and interfaces are designed to allow generic type parameters. This Java Generics tutorial shows examples of how to use generic type parameters with some of these classes. Once you have seen a few examples, you can figure out how to use generic type parameters in general.
You can also design your own classes, interfaces and methods to use usable with Java Generics - meaning enabling them to take type parameters. This Java Generics tutorial also shows how to do that.
Chapters:
0:00 Java Generics Introduction
0:24 Java Generics Example
8:32 Java For Each Loop Using Generics
9:37 Java Collections Support Generics
11:19 Java Generics in Your Own Classes (Method Level)
14:57 Java Generics in Your Own Classes (Class Level)
20:47 Java Generics in Your Own Classes (Field Level)
24:20 Class Objects as Generic Type Literals
28:15 Java Generics in Your Own Interfaces
34:39 Java Generic Wildcards
36:50 Java Generic Wildcards ?
40:59 Java Generic Wildcards ? extends SomeClass
44:57 Java Generic Wildcards ? super SomeClass
X (Twitter): @jjenkov
LinkedIn: https://www.linkedin.com/in/jakob-jenkov-4a3a8/
Java Generic Tutorial - text:
https://jenkov.com/tutorials/java-generics/index.html
-
LIVE
PandaSub2000
3 days agoLIVE 9:30pm ET | STAR WARS: OUTLAWS
769 watching -
LIVE
MissesMaam
4 hours agoISSA RUMBLE TAKEOVER BABY 💚✨
588 watching -
1:51:52
Kim Iversen
6 hours agoUS-Backed Al-Qaeda Takes Over Syria: Israel the Biggest Beneficiary — Were They Responsible?
81.7K48 -
1:54:02
Fresh and Fit
5 hours agoMoney Monday Call-In Show
49.4K8 -
28:33
Stephen Gardner
4 hours ago🔥Joe Biden SHOCKS the DNC...Then burns it down on way out!
59.1K71 -
1:04:33
JustPearlyThings
7 hours agoThe MISLEADING Tactics of the Feminist Agenda | Pearl Daily
22.7K15 -
1:26:57
Flyover Conservatives
23 hours agoLara Logan’s Explosive Take: Open Borders. The Future for J6 Hostages. The Fallout from Hunter Biden’s Pardon. | FOC Show
24.9K8 -
1:27:53
Adam Does Movies
8 hours ago $3.97 earnedIt's Kraven Time! First 8 Minutes Revealed + Moana 2's Huge Box Office! - LIVE
32.2K1 -
7:20:47
-
1:05:40
Donald Trump Jr.
10 hours agoAmerica to the FBI: We Only Take Kash, Live with Mike Davis | TRIGGERED Ep.195
152K124