Rules
, then is inferred as , then is inferred as , then is inferred as
Constraints
Example
Given the example below:
static <T extends Comparable<T>> T max(List<T> list)
List<Fruit> fruits = List.of(new Fruit(), new Apple());
Running max(fruits);
- Target type
T
<:Fruit
- Argument type
List<Fruit>
<:List<T>
, thusT
=Fruit
- Type parameter bound
T
<:Comparable<T>