Here you can find the source of charToBasicType(char c, Class
@SuppressWarnings("unchecked") public static <T> T charToBasicType(char c, Class<T> clazz)
//package com.java2s; //License from project: LGPL public class Main { @SuppressWarnings("unchecked") public static <T> T charToBasicType(char c, Class<T> clazz) { if (clazz.equals(Boolean.class)) return (T) Boolean.valueOf(charToBoolean(c)); if (clazz.equals(Byte.class)) return (T) charToByte(c); if (clazz.equals(Character.class)) return (T) Character.valueOf(c); if (clazz.equals(Short.class)) return (T) Short.valueOf((short) c); if (clazz.equals(Integer.class)) return (T) Integer.valueOf(c); if (clazz.equals(Long.class)) return (T) Long.valueOf(c); if (clazz.equals(Float.class)) return (T) Float.valueOf(c); if (clazz.equals(Double.class)) return (T) Double.valueOf(c); if (clazz.equals(String.class)) return (T) String.valueOf(c); return null; }/*from ww w . j a v a 2 s . c o m*/ public static boolean charToBoolean(char c) { return c != 0 ? true : false; } public static Byte charToByte(char c) { if (c >= Byte.MIN_VALUE && c <= Byte.MAX_VALUE) { return (byte) c; } return null; } public static byte charToByte(char c, byte defaultValue) { if (c >= Byte.MIN_VALUE && c <= Byte.MAX_VALUE) { return (byte) c; } return defaultValue; } }