OnJava8-Examples/generics/CompilerIntelligence.java
2015-05-29 14:18:51 -07:00

14 lines
422 B
Java

//: generics/CompilerIntelligence.java
// ©2015 MindView LLC: see Copyright.txt
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'
}
} ///:~