Tag

PECS

0 views collected around this technical thread.

DaTaobao Tech
DaTaobao Tech
Nov 6, 2024 · Fundamentals

Understanding Java Generics: Origins, Features, and the PECS Principle

Java generics, introduced in Java 5 to replace unsafe Object usage, provide compile‑time type safety, clearer code, and eliminate unchecked casts by allowing type‑parameterized classes, methods, and collections, while type erasure and bridge methods preserve backward compatibility, and the PECS rule (producer extends consumer super) guides safe use of wildcards through covariance and contravariance.

JavaPECSType Erasure
0 likes · 11 min read
Understanding Java Generics: Origins, Features, and the PECS Principle
Java Captain
Java Captain
Nov 15, 2017 · Fundamentals

Understanding Java Generics: Basics, Wildcards, Bounds, and Type Erasure

This article introduces Java generics, covering generic classes and methods, wildcard usage with the PECS principle, bounded type parameters, and the implications of type erasure, illustrating each concept with code examples and discussing common pitfalls such as generic arrays, bridge methods, and runtime type checks.

JavaPECSType Erasure
0 likes · 17 min read
Understanding Java Generics: Basics, Wildcards, Bounds, and Type Erasure
Qunar Tech Salon
Qunar Tech Salon
Feb 12, 2015 · Fundamentals

Understanding Java Generics: Motivation, Structure, and Usage

This article provides a comprehensive overview of Java generics, explaining their motivation, syntax, type‑safety benefits, class and method declarations, wildcard usage, and best‑practice principles such as PECS, while illustrating concepts with clear code examples.

CollectionsJavaPECS
0 likes · 12 min read
Understanding Java Generics: Motivation, Structure, and Usage