Hi,

Can anyone explain why the result of this code:
Java Code:
public class Test {

	public static void main(String[] args) {
		List<Test> a = g();
		System.out.println(a.get(0));
	}
	
	public static<E> List<E> g() {
		List<Integer> i = new ArrayList<Integer>();
		i.add(new Integer(1));
		return (List<E>)(i);
	}
	
}
is:
1
??

Line List<Test> a = g() invokes <Test> List<Test> Test.g(), so why the compiler allows to cast from List<Integer> to List<Test> in line return (List<E>)(i); ?

Thanks