Sometimes its useful to get the class name of an object. Syntax is easy:

Java Code:
		
TestClass obj = new TestClass();
System.out.println("Object obj belongs to Class: " + obj.getClass().getName());
Output:
Java Code:
Object obj belongs to Class: TestClass