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);

  1. Target type

    T <: Fruit

  2. Argument type

    List<Fruit> <: List<T>, thus T = Fruit

  3. Type parameter bound

    T <: Comparable<T>