We can make class Foo <T>, why can’t I call new T()?
I tried to understand, I know that T is a type variable, but didn’t get that answer… which is asked by friend, am also eager to know the answer… please, thanks in advance.
We can make class Foo <T> , why can’t I call new T() ?
Share
Because you cannot know if T is even instantiable, it could have a private constructor.
Imagine: