Here you can find the source of toBoolean(Object object)
public static final Boolean toBoolean(Object object)
//package com.java2s; /*/* w w w .jav a 2 s .c o m*/ * Copyright (C) 2008 feilong * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.Arrays; public class Main { public static final Boolean toBoolean(Object object) { if (null == object) { throw new IllegalArgumentException("object can't be null/empty!"); } return Boolean.parseBoolean(object.toString()); } public static final String toString(Object value) { if (null == value) { return null; } if (value instanceof String) { return (String) value; } if (value instanceof Object[]) { return Arrays.toString((Object[]) value); } //*************************************************************** // primitive ints if (value instanceof int[]) { return Arrays.toString((int[]) value); } // primitive long if (value instanceof long[]) { return Arrays.toString((long[]) value); } // primitive float if (value instanceof float[]) { return Arrays.toString((float[]) value); } // primitive double if (value instanceof double[]) { return Arrays.toString((double[]) value); } // primitive char if (value instanceof char[]) { return Arrays.toString((char[]) value); } // primitive boolean if (value instanceof boolean[]) { return Arrays.toString((boolean[]) value); } // primitive byte if (value instanceof byte[]) { return Arrays.toString((byte[]) value); } // primitive short if (value instanceof short[]) { return Arrays.toString((short[]) value); } return value.toString(); } }