📜  Java.lang布尔类

📅  最后修改于: 2020-11-15 02:54:56             🧑  作者: Mango


介绍

java.lang.Boolean类将原始类型boolean的值包装在一个对象中。布尔类型的对象包含一个布尔类型的字段。

类声明

以下是java.lang.Boolean类的声明-

public final class Boolean
   extends Object
      implements Serializable, Comparable

领域

以下是java.lang.Boolean类的字段-

  • 静态布尔FALSE-这是与原始值false相对应的布尔对象。

  • static Boolean TRUE-这是与原始值true相对应的布尔对象。

  • 静态Class TYPE-这是表示原始类型boolean的Class对象。

类的构造函数

Sr.No. Constructor & Description
1

Boolean(boolean value)

This allocates a Boolean object representing the value argument.

2

Boolean(String s)

This allocates a Boolean object representing the value true if the string argument is not null and is equal, ignoring case, to the string “true”.

类方法

Sr.No. Method & Description
1 boolean booleanValue()

This method returns the value of this Boolean object as a boolean primitive.

2 int compareTo(Boolean b)

This method compares this Boolean instance with another.

3 boolean equals(Object obj)

This method returns true if and only if the argument is not null and is a Boolean object that represents the same boolean value as this object.

4 static boolean getBoolean(String name)

This method returns true if and only if the system property named by the argument exists and is equal to the string “true”.

5 int hashCode()

This method returns a hash code for this Boolean object.

6 static boolean parseBoolean(String s)

This method parses the string argument as a boolean.

7 String toString()

This method returns a String object representing this Boolean’s value.

8 static String toString(boolean b)

This method returns a String object representing the specified boolean.

9 static Boolean valueOf(boolean b)

This method returns a Boolean instance representing the specified boolean value.

10 static Boolean valueOf(String s)

This method returns a Boolean with a value represented by the specified string.

方法继承

此类从以下类继承方法-

  • java.lang.Object