MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / main

Method main

generics/GenericsAndCovariance.java:8–18  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

6
7public class GenericsAndCovariance {
8 public static void main(String[] args) {
9 // Wildcards allow covariance:
10 List<? extends Fruit> flist = new ArrayList<>();
11 // Compile Error: can't add any type of object:
12 // flist.add(new Apple());
13 // flist.add(new Fruit());
14 // flist.add(new Object());
15 flist.add(null); // Legal but uninteresting
16 // We know it returns at least Fruit:
17 Fruit f = flist.get(0);
18 }
19}

Callers

nothing calls this directly

Calls 2

getMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected