Possible duplicate:
How to define an object class (in Java)? Java determines which class is an object
I have the following example of an incomplete method for comparing the object type of a given object
public void test(Object value) { if (value.getClass() == Integer) { System.out.println("This is an Integer"); }else if(value.getClass() == String){ System.out.println("This is a String"); }else if(value.getClass() == Float){ System.out.println("This is a Fload"); } }
we can call this method, for example
test("Test"); test(12); test(10.5f);
This method actually does not work, please help me make it work.
java object class
Harsha
source share