Here you can find the source of toBoolean(Object obj)
public static Boolean toBoolean(Object obj)
//package com.java2s; //License from project: Apache License public class Main { private static final Object NULL = null; public static Boolean toBoolean(Object obj) { if (isNull(obj)) { return getNull(); }/* ww w . j a va 2s.c om*/ if (obj instanceof Boolean) { return (Boolean) obj; } if ("true".equalsIgnoreCase(obj.toString())) { return Boolean.TRUE; } if ("false".equalsIgnoreCase(obj.toString())) { return Boolean.FALSE; } return getNull(); } public static boolean isNull(Object obj) { return obj == NULL; } @SuppressWarnings("unchecked") public static <T> T getNull() { return (T) NULL; } }