Answers for "java how to get class name from string"

3

java get classname

//Just the name of the class
myObject.getClass().getSimpleName();

//The name of the class with the package name
myObject.getClass().getName();
Posted by: Guest on March-23-2021
0

java get object from string name

try {
	ObjectType instance = getClass().getDeclaredField("name of var").get(ObjectType.class);
} catch (Exception e) {
	e.printStackTrace();
}
Posted by: Guest on October-26-2021

Code answers related to "java how to get class name from string"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language