1

Consider the following generic class:

class MyClass<T>{
    T field;//ok
    public void method (T t){...}//ok
    public <E> MyClass(E[] e){
        E ee= new E();// compile error
        T t= new T();// compile error
    }
}

Why we cant instanciate of T and E? We know all about of types T,E at run time. I think that the type parameters T,E can be considered as a some reference type.

St.Antario
  • 26,175
  • 41
  • 130
  • 318

0 Answers0