Answers for "java get class from string"

1

java get class by string

//get an according class variable
String className = "MyClass";
Class<?> cls = Class.forName(className);

//create instance of that class
Object myInstance = cls.newInstance();
Posted by: Guest on December-27-2020
-1

java get class by string name

//get an according class variable
String className = "MyClass";
Class<?> cls = Class.forName(className);

//create instance of that class
Object myInstance = scl.newInstance();
Posted by: Guest on December-26-2020

Code answers related to "java get class from string"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language