Here you can find the source of castToChar(Object value)
public static final Character castToChar(Object value)
//package com.java2s; //License from project: Apache License public class Main { public static final Character castToChar(Object value) { if (value == null) { return null; }/* w ww. ja v a2 s .c om*/ if (value instanceof Character) { return (Character) value; } if (value instanceof String) { String strVal = (String) value; if (strVal.length() == 0) { return null; } if (strVal.length() != 1) { throw new NumberFormatException("can not cast to byte, value : " + value); } return strVal.charAt(0); } throw new NumberFormatException("can not cast to byte, value : " + value); } }