How to get the parameter names of an object's constructors (reflection)?
- by Tom
Say I somehow got an object reference from an other class:
Object myObj = anObject;
Now I can get the class of this object:
Class objClass = myObj.getClass();
Now, I can get all constructors of this class:
Constructor[] constructors = objClass.getConstructors();
Now, I can loop every constructor:
if (constructors.length > 0)
{
for…