https://github.com/rameshmf/java-generics-guide
Guide to Java Generics
https://github.com/rameshmf/java-generics-guide
generic generic-methods java-generics java-generics-guide java-generics-wildcards
Last synced: about 1 month ago
JSON representation
Guide to Java Generics
- Host: GitHub
- URL: https://github.com/rameshmf/java-generics-guide
- Owner: RameshMF
- Created: 2018-08-14T10:12:20.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-23T05:31:23.000Z (almost 7 years ago)
- Last Synced: 2025-04-07T18:24:10.622Z (2 months ago)
- Topics: generic, generic-methods, java-generics, java-generics-guide, java-generics-wildcards
- Language: Java
- Size: 26.4 KB
- Stars: 13
- Watchers: 1
- Forks: 17
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Generics were added in Java 5 to provide compile-time type checking and removing the risk of ClassCastException that was common while working with collection classes.
Java Generics Guide
Java Generics - Generics Basics
Java Generics Examples
Java Generic Methods Examples
Java Generic Interface Examples
Java Generic Class Examples
Java Generics Multiple Type Parameters Example
Java Generics Wildcards Example
Java Generics Upper Bounded Wildcards Example
Java Generics Lower Bounded Wildcards ExampleSINCE Java 5, generics have been a part of the language. Before generics, you had to cast every object you read from a collection. If someone accidentally inserted an object of the wrong type, casts could fail at runtime. With generics, you tell the compiler what types of objects are permitted in each collection. The compiler inserts casts for you automatically and tells you at compile time if you try to insert an object of the wrong type. This results in programs that are both safer and clearer, but these benefits, which are not limited to collections, come at a price. This chapter tells you how to maximize the benefits and minimize the complications.