Searching...
Sunday, 14 October 2012

How to get class name from a Java object?

10:11

Example

package com.vinod.test;

public class GetClassName {

    public static void main(String[] args) {
         Integer integer=new Integer("10");
         System.out.println("Created Object "+integer);
         Class<? extends Integer> className=integer.getClass();
         System.out.println("Objects class Name "+className);
    }

}
 

Output

Created Object 10

Objects class Name class java.lang.Integer


0 comments: