samedi 5 décembre 2015

Java Reflection for creating new objects

Is there a way to create primitive data type variables use Java Reflection?

For example,

public Object createObj(String type, String value){
  if(type.compareTo("char") == 0)
    //return a char
  else if(type.compareTo("int") == 0)
    //return an int
  ....
}





Aucun commentaire:

Enregistrer un commentaire