jeudi 21 mai 2015

Can i use a string variable as a datatype to create other variables in java

I use reflection to invoke a method as:

method.invoke(someObject, null);

The problem is, I want to use the value that this method returns without having it's data type known before hand. I have the knowledge of the data type in a string variable, say

String type = "String";

Is it possible to do something equivalent of this-

type variable = method.invoke(someObject, null)





Aucun commentaire:

Enregistrer un commentaire