Here you can find the source of toChar(Object value)
public static char toChar(Object value)
//package com.java2s; //License from project: Open Source License public class Main { public static char toChar(Object value, char defaultValue) { try {//w w w . j av a 2 s . c o m return toChar(value); } catch (RuntimeException e) { return defaultValue; } } public static char toChar(Object value) { if (null == value) { throw new RuntimeException("Impossible to convert " + value + " from " + (null == value ? "unknown" : value.getClass() .getName()) + " to " + char.class.getName()); } if (value instanceof Character) { return ((Character) value).charValue(); } if (value instanceof Number) { int int_value = ((Number) value).intValue(); return (char) int_value; } if (value instanceof String && 1 == ((String) value).length()) { return ((String) value).charAt(0); } throw new RuntimeException("Impossible to convert " + value + " from " + (null == value ? "unknown" : value.getClass().getName()) + " to " + char.class.getName()); } }