Originally posted by kumarth ravi:
It was compiled but thrown a Class cast exception.
Originally posted by Olivier Croisier:
You cannot be sure that the real type (T) will have a no-arg constructor.
So you cannot write T t = new T() !
Originally posted by Gregg Bolinger:
While I think it's excellent for any developer to have a firm grasp of memory use when programming and how all that works, from a beginner's perspective, the beauty of Java is that you don't really need to concern yourself with either.
The Java programming language provides mechanisms for access control, to prevent the users of a package or class from depending on unnecessary details of the implementation of that package or class. If access is permitted, then the accessed entity is said to be accessible.
Note that accessibility is a static property that can be determined at compile time; it depends only on types and declaration modifiers...