The moose likes Java in General and the fly likes Java reflection 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 » Java in General
Bookmark "Java reflection" Watch "Java reflection" New topic

Java reflection

Shenaz Assu
Ranch Hand

Joined: Sep 21, 2007
Posts: 32
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

Joined: Aug 16, 2005
Posts: 14074

Have a look at the API documentation of class Class. Try something like this:

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Java reflection
Similar Threads
Map Object to HashMap
Listening for a state change of a POJO
serialization with Java refection
Poorly covered topics ?
Dynamic variable names