Answers for "get class of this object"

1

how to find the class of an object java

// obj instanceof Class

/*example*/

String str = "a String made by the String class";

if(str instanceof String) System.out.println("This is True");
if(str instanceof float) System.out.println("This will never be on your screen");
Posted by: Guest on November-22-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 "get class of this object"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language