bounded type parameter

A type parameter restricted to types that support a capability, such as T extends Comparable<T>, so the code can call that capability.

In more detail

An upper bound written with extends lets a generic method call the bound's methods, such as compareTo, without a cast. The compiler rejects type arguments that do not meet the bound. A lower bound, written with super, appears in wildcards for collections you write into.

Example

public static <T extends Comparable<T>> T larger(T left, T right)

Related terms

Taught in

References

Certification courses