mardi 6 janvier 2015

How can I check a class has no arguments constructor


Object obj = new Object();
try {
obj.getClass().getConstructor();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
dosomething();
e.printStackTrace();
}


I don't want check like this, because it throw a Exception.


Is there another way?






Aucun commentaire:

Enregistrer un commentaire