I've studied generics, and i know that the type safe are removed through type erasure during compilation. But the way i used to interpret the code was; whenever there is a class type is defined, i used to replace all the occurrences of generic type with the class type. for ex, in the above code:
Test<String> t = new Test(new Integer(1)); As Test class is defined with a generic parameter type 'Test<t>' and in the above line, the reference is defined as 'Test<String>', in my mind, i used to replace all the occurrences of 'T' with 'String' to check for compiler errors. I'm confused here, because the constructor is defined as 'Test(T g)' and in the above code we are passing Integer in the constructor and the parameter type is String.
I know my stupid brain is missing something here and i'm hopelessly confused.

Can some one please clarify this with good example.