For each primitive data type there is Class and which is called as wrapper class.
Wrapper classes allows us to use of polymorphism.
Tutorial url: Wrapper Classes
Example Program:
public class WrapperClassExample { public void testPoly(Object s){ if(s instanceof Integer){ System.out.println("It is an Integer"); }else if(s instanceof Character){ System.out.println("It is a Character"); }else if(s instanceof Boolean){ System.out.println("It is a Boolean"); }else if(s instanceof Float){ System.out.println("It is a Float"); }else if(s instanceof Double){ System.out.println("It is a Double"); }else if(s instanceof Long){ System.out.println("It is a Long"); }else if(s instanceof Short){ System.out.println("It is a Short"); }else if(s instanceof Byte){ System.out.println("It is a Byte"); }else{ System.out.println("Given object is not a object of Wrapper class"); } } } public class WrapperClassTest { public static void main(String[] args) { int a = 50; char b = 'G'; long c = 100; boolean d = true; short e = 20; byte f = 10; float g = 10.5f; double h = 13.0308340; WrapperClassExample wce = new WrapperClassExample(); wce.testPoly(a); wce.testPoly(b); wce.testPoly(c); wce.testPoly(d); wce.testPoly(e); wce.testPoly(f); wce.testPoly(g); wce.testPoly(h); } } OutPut: It is an Integer It is a Character It is a Long It is a Boolean It is a Short It is a Byte It is a Float It is a Double