This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java reflection

 
Shenaz Assu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am new to java reflection. I have a Class c variable. I need to check if its an instance of Number.class. If so, i'll need to invoke anyone of the constructors of the subclasses of Number (Long, Double, etc..) depending upon the variable c. Is it possible using the reflection.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the API documentation of class Class. Try something like this:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic