lundi 5 septembre 2016

Java: Add a Class Property Dynamically

I'm relatively new to Java and have dug through the reflection capabilities, but for some reason can't figure out the following:

I need to get the String name of an instantiate class. Seems that I cannot find a way to do this with reflection, so I thought to add a class property dynamically that would contain the name of the class as a String.

How would I go about that?

Alternatively, I thought of creating a Public String property in the class that I assign the name of the instantiated class in the constructor. Didn't really figure out how to do that either.





Aucun commentaire:

Enregistrer un commentaire