This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes get class of type parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "get class of type parameter" Watch "get class of type parameter" New topic
Author

get class of type parameter

nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
I have something like this:



and while running the programm the ? can be a type of (for example) the object Users or Persons:



How can I get the class of the type parameter (which, in this case, can only be Users or Persons)?

something like;



Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

You can't, unfortunately. This information is removed by the compiler. This is called type erasure.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: get class of type parameter
 
Similar Threads
regarding objects and collections
Iterating through unknown enum type variable
JDBC Realm using Resource
What is wrong with the following code?
regarding Objects and collections