www.pudn.com > j2me_cldc-1_1-fcs-src-winunix.rar > Boolean.java
/* * Copyright © 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * */ package java.lang; /** * The Boolean class wraps a value of the primitive type *booleanin an object. An object of type *Booleancontains a single field whose type is *boolean. * * @author Arthur van Hoff * @version 12/17/01 (CLDC 1.1) * @since JDK1.0, CLDC 1.0 */ public final class Boolean { /** * TheBooleanobject corresponding to the primitive * valuetrue. */ public static final Boolean TRUE = new Boolean(true); /** * TheBooleanobject corresponding to the primitive * valuefalse. */ public static final Boolean FALSE = new Boolean(false); /** * The value of the Boolean. */ private boolean value; /** * Allocates aBooleanobject representing the *valueargument. * * @param value the value of theBoolean. */ public Boolean(boolean value) { this.value = value; } /** * Returns the value of this Boolean object as a boolean * primitive. * * @return the primitivebooleanvalue of this object. */ public boolean booleanValue() { return value; } /** * Returns a String object representing this Boolean's value. * If this object represents the valuetrue, a string equal * to"true"is returned. Otherwise, a string equal to *"false"is returned. * * @return a string representation of this object. */ public String toString() { return value ? "true" : "false"; } /** * Returns a hash code for this Boolean object. * * @return the integer 1231 if this object represents * true; returns the integer 1237 if this * object represents false. */ public int hashCode() { return value ? 1231 : 1237; } /** * Returnstrueif and only if the argument is not *nulland is aBooleanobject that * represents the samebooleanvalue as this object. * * @param obj the object to compare with. * @returntrueif the Boolean objects represent the * same value;falseotherwise. */ public boolean equals(Object obj) { if (obj instanceof Boolean) { return value == ((Boolean)obj).booleanValue(); } return false; } }