Browse by Topic

Popular

Latest

Latest Java Posts

A conceptual illustration of a Java generic collection box labeled '? extends Number' containing type icons for Integer, Double, and Float, representing type safety and flexibility.
Java

Java Upper Bounded Wildcard: Usage and Examples

Use Java upper bounded wildcards (`<? extends T>`) to write flexible, type-safe generic code: read any subtype collection, understand when adding is forbidden, and decide between a wildcard and a generic type parameter.

Java genericswildcardstype boundsgeneric methods
Diagram showing a Java List<?> with an unknown element type and the compiler blocking an add operation.
Java

Java Unbounded Wildcard: What List<?> Means

Learn how the Java unbounded wildcard works in generics, when to use `List<?>`, and why adding elements is a compile-time error.

Java genericsWildcardsType safetyType erasure
Diagram showing three Java wildcard forms and how they constrain reading and writing elements in a generic collection.
Java

Java Wildcard: Using ?, extends, and super in Generics

java wildcard: Explains the three Java wildcard forms — ?, ? extends, and ? super — with the PECS rule, wildcard capture, and type erasure behavior.

Java GenericsWildcardsPECSType Safety
Diagram showing a lower bound wildcard in Java generics, with Integer at the bottom and Number and Object above it, illustrating the super bound relationship.
Java

Java Generic Super Bound: Using ? super T

Learn how the `? super T` lower bound wildcard works in Java generics, when to use it, and how the PECS rule guides producer and consumer wildcard choices.

Java GenericsWildcardsLower BoundsPECS
Diagram showing a generic type parameter constrained by an upper bound in Java, with a class hierarchy and type safety.
Java

Java Generic Extends Bound: Syntax and Use Cases

The `extends` bound in Java generics restricts type arguments to a subtype of a named class or interface. Learn the syntax, multiple bounds, wildcard differences, and common pitfalls.

Java genericsBounded type parametersType safetyJava programming
Illustration of a Java bounded type parameter restricting generic types with a boundary symbol.
Java

Java Bounded Type Parameter: Syntax and Use Cases

Understand Java bounded type parameters: declare bounds, call bound methods, use multiple bounds, and avoid common generic pitfalls.

Java genericstype boundstype safetygeneric methods
Diagram showing a Java generic class with two type parameters T and U connecting to different data types.
Java

Java Generic Multiple Type Parameters: Syntax and Usage

Learn how to use multiple type parameters in Java generic classes and methods, including type bounds, inference, wildcards, and type erasure.

Java genericsmultiple type parameterstype safetygeneric methods
Diagram showing a Java constructor with type parameters and type inference arrows flowing into a generic box.
Java

Java Generic Constructor: Syntax and Type Inference

java generic constructor: Understand Java generic constructors: how to declare type parameters on constructors, how type inference works, and when to use them for type...

JavaGenericsType InferenceDiamond Operator
Diagram showing a generic type parameter T being replaced by concrete types at compile time in Java.
Java

Java Generic Type Parameters: Syntax and Behavior

Understand Java generic type parameters with practical examples: declaration syntax, bounds, wildcards, type erasure, and common compile-time errors.

java genericstype parameterstype safetywildcards
Diagram showing a Java generic interface with type parameter T connecting to multiple implementations.
Java

Java Generic Interface: Syntax and Implementation

Java generic interfaces let you define a reusable contract that stays type-safe at compile time. See how to declare, implement, bound, and use them in practice.

generic typestype safetyJava genericsinterface design