Topic: Question on language Java.

Here a small code sample: class RsdnJavaTopic {static class Base <T> {public Base () {} T ret () {return null;}} static class Extends2 <T> extends Base <List <T>> {List <T> items; public Extends2 () {}} static class Extends3 extends Extends2 <String> {public Extends3 () {} @Override List <String> ret () {System.out.println ("Extends3"); return null;}} static class Extends4 extends Extends2 {public Extends4 () {} @Override List <Integer> ret () {System.out.println ("Extends4"); return null;}} public static void main (String [] args) {Extends4 ex4 = new Extends4 (); Base <List> ptr = ex4; ptr.ret (); Extends3 ex3 = new Extends3 ();//ptr = ex3; Base <List <String>> ptr2 = ex3; ptr.ret (); ptr2.ret (); ptr2 = ex4; ptr2.ret ();} } Why the line (it is impossible to result types) is not compiled , but the penultimate at the same time is compiled. And in what a difference between inheritance variants extends Extends2 <String> and extends Extends2 and what of them is more preferable for using?


Re: Question on language Java.