i have almost completed the generic chapter and these are some doubts in my mind. These doubts will help me to finish this chapter(which i decided to complete by today)
1. if List(?) is a reifiable then why List(? extends Object) is not a reifiable type ?? (even though Type Erasure will convert both into List(Object) according to defination reifiable is the type which is completely represented at runtime i.e. no useful information is removed(type information)
2. what is the difference between these two generics method
one difference is that first one is the class method, i.e no class instance is needed to call that method. Is there any other difference in the working of these method ?
3. why static generic method cannot use Type parameter defined by class
my reason for this: since static method can be called even if there is no instance and if there is no instance of generic class, the type parameter are unknown... so they are not allowed
4. why Type parameter cant be static
my reason :a) since static variable are the class variable and get there value at compile time, but Type parameter are unknown at compiler ...so this is not allowed b) since static varibale are class variable and the original variable itself is shared among all the instances(not copy), so for generics it will be difficult for the compiler to predict the type of variable if there are multiple instance ie. Gen<Integer> g=new Gen<>(12); Gen<Stringr> g=new Gen<>("hello"); so now it is impossible for compiler to know about the type of the variable obj .
it is valid but,
is not a valid class..why super is not allowed here ??
6. how can i see the type erased code by the compler?? i tried
javap Gen but is not working. It simply showing T type for the unbounded type, should show Object