Monday, December 12, 2011

Java: Get the class name of any Object


Share at Facebook

Using the getClass() method of any object, you can easily obtain the name of the class of that Object. Below is a simple code snippet to clear the things.


TestClass t = new TestClass();
System.out.println(t.getClass().getName());
// output: TestClass




No comments: