• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get class of type parameter

 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't, unfortunately. This information is removed by the compiler. This is called type erasure.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic