Skip to content

Instantly share code, notes, and snippets.

@itang
Created September 20, 2012 01:54
Show Gist options
  • Save itang/3753531 to your computer and use it in GitHub Desktop.
Save itang/3753531 to your computer and use it in GitHub Desktop.
获取基本类型的包装类
public class PrimitiveTypeTest {
public static void main(String[] args) {
System.out.println(getPrimitiveWrapperType(int.class));
}
private static Class<?> getPrimitiveWrapperType(Class<?> class1) {
if (class1 == java.lang.Integer.TYPE) { // 不是 class1 == java.lang.Integer.class
return Integer.class;
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment