Java tutorial
//package com.java2s; public class Main { /** * Helper method for finding wrapper type for given primitive type (why isn't * there one in JDK?) */ public static Class<?> wrapperType(Class<?> primitiveType) { if (primitiveType == Integer.TYPE) { return Integer.class; } if (primitiveType == Long.TYPE) { return Long.class; } if (primitiveType == Boolean.TYPE) { return Boolean.class; } if (primitiveType == Double.TYPE) { return Double.class; } if (primitiveType == Float.TYPE) { return Float.class; } if (primitiveType == Byte.TYPE) { return Byte.class; } if (primitiveType == Short.TYPE) { return Short.class; } if (primitiveType == Character.TYPE) { return Character.class; } throw new IllegalArgumentException("Class " + primitiveType.getName() + " is not a primitive type"); } }