Duplicate :
|
|
Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Description: Compiler throws error for what seems to be a valid cast to a type in which both the qualifying type and inner class are parameterized. <code> bash-3.00$ <code> bash-3.00$ cat GenericOuter.java public class GenericOuter<S> { class GenericInner<T> extends LinkedList<T>{ } public static void main(String...args){ GenericOuter.GenericInner g1 = ( GenericOuter.GenericInner)new LinkedList<String>(); GenericOuter<String>.GenericInner<String> g2 = ( GenericOuter<String>.GenericInner<String>)new LinkedList<String>(); //Compilation Error } } </code> Compilation result is : <output> GenericOuter.java:8: ')' expected GenericOuter<String>.GenericInner<String> g2 = ( GenericOuter<String>.GenericInner<String>)new LinkedList<String>(); //Compilation Error ^ GenericOuter.java:8: ';' expected GenericOuter<String>.GenericInner<String> g2 = ( GenericOuter<String>.GenericInner<String>)new LinkedList<String>(); //Compilation Error ^ GenericOuter.java:8: illegal start of expression GenericOuter<String>.GenericInner<String> g2 = ( GenericOuter<String>.GenericInner<String>)new LinkedList<String>(); //Compilation Error </output> <version> /net/sqindia/export/disk09/jdk/7/latest/binaries/solsparc/bin/java -version java version "1.7.0-ea" Java(TM) SE Runtime Environment (build 1.7.0-ea-b24) Java HotSpot(TM) Client VM (build 12.0-b01, mixed mode) bash-3.00$ uname -a SunOS hrajan 5.10 Generic sun4u sparc SUNW,Sun-Blade-100
|