Here you can find the source of toBoolean(Object obj)
public static Boolean toBoolean(Object obj) throws IllegalArgumentException
//package com.java2s; //License from project: Apache License public class Main { public static Boolean toBoolean(Object obj) throws IllegalArgumentException { if (obj == null) { throw new IllegalArgumentException("obj is null"); }// w ww.j a va 2 s. c om if (obj instanceof Boolean) { return (Boolean) obj; } if (obj instanceof String) { String str = (String) obj; return new Boolean(str.equalsIgnoreCase("true") || str.equalsIgnoreCase("t") || str.equalsIgnoreCase("y") || str.equalsIgnoreCase("yes") || str.equalsIgnoreCase("1")); } throw new IllegalArgumentException("Unable to convert object of type '" + obj.getClass() + "' to Boolean."); } }