samedi 16 mai 2015

Use of forName and Class.forName and isInstance

I want to pass a name of a class as an argument in a print method. For example : public void printAll(String className) I've also created a list of animals. I want to print only the nodes that belong in class with name className.

i tried to use something like this : node tmp; if (Class.forName(className).isInstance(tmp.getValue())

Any help?





Aucun commentaire:

Enregistrer un commentaire