Sometimes its useful to get the class name of an object. Syntax is easy:
Output:Code:
TestClass obj = new TestClass();
System.out.println("Object obj belongs to Class: " + obj.getClass().getName());
Code:Object obj belongs to Class: TestClass
Printable View
Sometimes its useful to get the class name of an object. Syntax is easy:
Output:Code:
TestClass obj = new TestClass();
System.out.println("Object obj belongs to Class: " + obj.getClass().getName());
Code:Object obj belongs to Class: TestClass