• Post Reply Bookmark Topic Watch Topic
  • New Topic

using reflection with generics  RSS feed

 
Clara Zetkin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I might have not understood generics complety, what is the right way to handle this kind of problem:

How can I get rid of the cast (T)? This way, I could just use Object and not use Generics at all, but I want to make sure to a return an object of the same type as the parameter. Yes, I'm aware of the generics tutorial but I didn't find an answer there. Thanks for suggestions!
 
Paul Clapham
Sheriff
Posts: 22721
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have a Java 5 compiler on this machine so I can't check it out, but try something like this:
 
Clara Zetkin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul,

that got me closer. I keep trying!
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!