OnJava8-Examples/generics/CompilerIntelligence.java

14 lines
395 B
Java
Raw Normal View History

2015-09-07 11:44:36 -06:00
// generics/CompilerIntelligence.java
2015-06-15 17:47:35 -07:00
import java.util.*;
public class CompilerIntelligence {
public static void main(String[] args) {
List<? extends Fruit> flist =
Arrays.asList(new Apple());
Apple a = (Apple)flist.get(0); // No warning
flist.contains(new Apple()); // Argument is 'Object'
flist.indexOf(new Apple()); // Argument is 'Object'
}
2015-09-07 11:44:36 -06:00
}
/* Output: (None) */