JDK1.8 API翻译(第二弹:Boolean)

API文档链接如下:
https://docs.oracle.com/javase/8/docs/api/java/lang/Boolean.html

java.lang.Object
java.lang.Boolean
All Implemented Interfaces:
Serializable, Comparable

public final class Boolean
extends Object
implements Serializable, Comparable
The Boolean class wraps a value of the primitive type boolean in an object. An object of type Boolean contains a single field whose type is boolean.
In addition, this class provides many methods for converting a boolean to a String and a String to a boolean, as well as other constants and methods useful when dealing with a boolean.

Boolean类对基本类型boolean进行了包装。一个Boolean对象只包含一个字段,其类型为boolean。
另外,该类还提供了许多将boolean转换为String和将String转换为boolean的方法,以及在处理boolean时有用的其他常量和方法。

Since:
JDK1.0
See Also:
Serialized Form
Field Summary
属性概要

Fields
属性
static Boolean FALSE
The Boolean object corresponding to the primitive value false.
对应着原始值false的Boolean对象。

static Boolean TRUE
The Boolean object corresponding to the primitive value true.
对应着原始值true的Boolean对象。

static Class<Boolean> TYPE
The Class object representing the primitive type boolean.
表示原始类型boolean的类。

Constructor Summary
构造方法概要

Constructors
构造方法
Boolean(boolean value)
Allocates a Boolean object representing the value argument.
分配一个Boolean对象,使用boolean参数value的值。

Boolean(String s)
Allocates a Boolean object representing the value true if the string argument is not null and is equal, ignoring case, to the string “true”.
分配一个Boolean对象,如果String参数不是null并且等于“true”(忽略大小写),则表示true。

Method Summary
方法概要

boolean booleanValue()
Returns the value of this Boolean object as a boolean primitive.
返回此Boolean对象的值,返回的是一个基本类型boolean。

static int compare(boolean x, boolean y)
Compares two boolean values.
比较两个boolean值。

int compareTo(Boolean b)
Compares this Boolean instance with another.
将此Boolean实例与另一个进行比较。

boolean equals(Object obj)
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.
返回true当且仅当参数不为空,并且是一个和该对象表示同样boolean值的Boolean对象。

static boolean getBoolean(String name)
Returns true if and only if the system property named by the argument exists and is equal to the string “true”.
返回true当且仅当以参数命名的系统属性存在且等于字符串”true”。

int hashCode()
Returns a hash code for this Boolean object.
返回此Boolean对象的hash code。

static int hashCode(boolean value)
Returns a hash code for a boolean value; compatible with Boolean.hashCode().
返回一个boolean值的哈希码; 兼容Boolean.hashCode()。

static boolean logicalAnd(boolean a, boolean b)
Returns the result of applying the logical AND operator to the specified boolean operands.
返回对指定boolean操作数进行逻辑与运算的结果。

static boolean logicalOr(boolean a, boolean b)
Returns the result of applying the logical OR operator to the specified boolean operands.
返回对指定boolean操作数进行逻辑或运算的结果。

static boolean logicalXor(boolean a, boolean b)
Returns the result of applying the logical XOR operator to the specified boolean operands.
返回对指定boolean操作数进行逻辑异或运算的结果。

static boolean parseBoolean(String s)
Parses the string argument as a boolean.
将String参数转换成boolean。

String toString()
Returns a String object representing this Boolean’s value.
返回一个表示此Boolean值的String对象。

static String toString(boolean b)
Returns a String object representing the specified boolean.
返回一个表示指定boolean值的String对象。

static Boolean valueOf(boolean b)
Returns a Boolean instance representing the specified boolean value.
返回一个表示指定boolean值的Boolean对象。

static Boolean valueOf(String s)
Returns a Boolean with a value represented by the specified string.
返回一个表示指定String的Boolean对象。

Methods inherited from class java.lang.Object
从java.lang.Object继承而来的方法
clone, finalize, getClass, notify, notifyAll, wait, wait, wait

Field Detail
属性详细信息

TRUE
public static final Boolean TRUE
The Boolean object corresponding to the primitive value true.
对应着原始值true的Boolean对象。

FALSE
public static final Boolean FALSE
The Boolean object corresponding to the primitive value false.
对应着原始值false的Boolean对象。

TYPE
public static final Class<Boolean> TYPE
The Class object representing the primitive type boolean.
表示原始类型boolean的类。

Since:
JDK1.1

Constructor Detail
构造方法详细信息

Boolean
public Boolean(boolean value)
Allocates a Boolean object representing the value argument.
Note: It is rarely appropriate to use this constructor. Unless a new instance is required, the static factory valueOf(boolean) is generally a better choice. It is likely to yield significantly better space and time performance.
分配一个Boolean对象,使用boolean参数value的值。
注意:很少使用这个构造函数。静态工厂valueOf(boolean)通常是一个更好的选择,除非需要新的实例。它可能有明显更好的空间和时间性能。

Parameters:
value - the value of the Boolean.
value - Boolean的值.

Boolean
public Boolean(String s)
Allocates a Boolean object representing the value true if the string argument is not null and is equal, ignoring case, to the string “true”. Otherwise, allocate a Boolean object representing the value false. Examples:
new Boolean(“True”) produces a Boolean object that represents true.
new Boolean(“yes”) produces a Boolean object that represents false.
分配一个Boolean对象,如果String参数不是null并且等于“true”(忽略大小写),则表示true。否则表示false。例:
new Boolean(“True”)生成一个Boolean对象,表示true 。
new Boolean(“yes”)生成一个Boolean对象,表示false 。

Parameters:
s - the string to be converted to a Boolean.
s - 要被转换成Boolean的String.

Method Detail
方法详细信息

parseBoolean
public static boolean parseBoolean(String s)
Parses the string argument as a boolean. The boolean returned represents the value true if the string argument is not null and is equal, ignoring case, to the string “true”.
Example: Boolean.parseBoolean(“True”) returns true.
Example: Boolean.parseBoolean(“yes”) returns false.
将String参数转换成boolean。如果字符串参数不为空且等于字符串”true”(忽略大小写),则返回的boolean值true。
例: Boolean.parseBoolean(“True”)返回true 。
例: Boolean.parseBoolean(“yes”)返回false 。

Parameters:
s - the String containing the boolean representation to be parsed
s - boolean式样的字符串。

Returns:
the boolean represented by the string argument
由String参数表示的boolean值。

Since:
1.5

booleanValue
public boolean booleanValue()
Returns the value of this Boolean object as a boolean primitive.
返回此Boolean对象的值,返回的是一个基本类型boolean。

Returns:
the primitive boolean value of this object.
该对象的基本类型boolean值。

valueOf
public static Boolean valueOf(boolean b)
Returns a Boolean instance representing the specified boolean value. If the specified boolean value is true, this method returns Boolean.TRUE; if it is false, this method returns Boolean.FALSE. If a new Boolean instance is not required, this method should generally be used in preference to the constructor Boolean(boolean), as this method is likely to yield significantly better space and time performance.
返回一个表示指定boolean值的Boolean对象。如果指定的boolean值为true,该方法返回Boolean.TRUE; 如果是false,该方法返回Boolean.FALSE。如果不需要新的Boolean实例,则该方法通常比构造函数Boolean(boolean)更好,因为该方法可能会有明显更好的空间和时间性能。

Parameters:
b - a boolean value.
b - 一个boolean值。

Returns:
a Boolean instance representing b.
表示b的一个Boolean实例。

Since:
1.4

valueOf
public static Boolean valueOf(String s)
Returns a Boolean with a value represented by the specified string. The Boolean returned represents a true value if the string argument is not null and is equal, ignoring case, to the string “true”.
返回一个表示指定String的Boolean对象。如果字符串参数不为空且等于字符串”true”(忽略大小写),则返回的boolean值true。

Parameters:
s - a string.
s - 一个String

Returns:
the Boolean value represented by the string.
表示参数String的Boolean对象

toString
public static String toString(boolean b)
Returns a String object representing the specified boolean. If the specified boolean is true, then the string “true” will be returned, otherwise the string “false” will be returned.
返回一个表示指定boolean值的String对象。如果指定的boolean为true,那么返回字符串”true”,否则返回字符串”false”。

Parameters:
b - the boolean to be converted
b - 要转换的boolean值。

Returns:
the string representation of the specified boolean
表示指定boolean值的String对象。

Since:
1.4

toString
public String toString()
Returns a String object representing this Boolean’s value. If this object represents the value true, a string equal to “true” is returned. Otherwise, a string equal to “false” is returned.
返回一个表示该Boolean值的String对象。如果该对象表示的值为true,则返回字符串”true”,否则返回字符串”false”。

Overrides:
toString in class Object

Returns:
a string representation of this object.
表示该Boolean值的String对象。

hashCode
public int hashCode()
Returns a hash code for this Boolean object.
返回此Boolean对象的hash code。

Overrides:
hashCode in class Object

Returns:
the integer 1231 if this object represents true; returns the integer 1237 if this object represents false.
如果该对象表示true,则返回整数1231;如果该对象表示false,则返回整数1237.

See Also:
Object.equals(java.lang.Object), System.identityHashCode(java.lang.Object)

hashCode
public static int hashCode(boolean value)
Returns a hash code for a boolean value; compatible with Boolean.hashCode().
返回一个boolean值的hash code; 兼容Boolean.hashCode()。

Parameters:
value - the value to hash
要hash的值。

Returns:
a hash code value for a boolean value.
boolean值的hash code

Since:
1.8

equals
public boolean equals(Object obj)
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.
返回true当且仅当参数不为空,并且是一个和该对象表示同样boolean值的Boolean对象。

Overrides:
equals in class Object

Parameters:
obj - the object to compare with.
obj - 要用来比较的对象。

Returns:
true if the Boolean objects represent the same value; false otherwise.
如果Boolean对象表示同样的值则返回true,否则返回false。

See Also:
Object.hashCode(), HashMap

getBoolean
public static boolean getBoolean(String name)
Returns true if and only if the system property named by the argument exists and is equal to the string “true”. (Beginning with version 1.0.2 of the JavaTM platform, the test of this string is case insensitive.) A system property is accessible through getProperty, a method defined by the System class.
If there is no property with the specified name, or if the specified name is empty or null, then false is returned.
返回true当且仅当以参数命名的系统属性存在且等于字符串”true”。(从Java平台的1.0.2版本开始,该字符串不区分大小写。)系统属性可通过getProperty来获取,这个方法是由System类定义的。
如果没有指定名称的属性,或者指定的名称为空字符串或为空,则返回false 。

Parameters:
name - the system property name.
name - 系统属性名称。

Returns:
the boolean value of the system property.
系统属性的boolean值。

Throws:
SecurityException - for the same reasons as System.getProperty
SecurityException - 与System.getProperty相同的原因。

See Also:
System.getProperty(java.lang.String), System.getProperty(java.lang.String, java.lang.String)

compareTo
public int compareTo(Boolean b)
Compares this Boolean instance with another.
将此Boolean实例与另一个进行比较。

Specified by:
compareTo in interface Comparable<Boolean>

Parameters:
b - the Boolean instance to be compared
b - 用来比较的Boolean对象。

Returns:
zero if this object represents the same boolean value as the argument; a positive value if this object represents true and the argument represents false; and a negative value if this object represents false and the argument represents true
如果该对象和参数表示相同的boolean值,则返回0;如果该对象表示true而参数表示false,则返回一个正值;如果该对象表示false而参数表示true,则返回一个负值。

Throws:
NullPointerException - if the argument is null
NullPointerException - 如果参数为空。

Since:
1.5
See Also:
Comparable

compare
public static int compare(boolean x, boolean y)
Compares two boolean values. The value returned is identical to what would be returned by:
Boolean.valueOf(x).compareTo(Boolean.valueOf(y))
比较两个boolean值。返回的值与以下返回值相同:
Boolean.valueOf(x).compareTo(Boolean.valueOf(y))

Parameters:
x - the first boolean to compare
y - the second boolean to compare
x - 要比较的第一个boolean
y - 要比较的第二个boolean

Returns:
the value 0 if x == y; a value less than 0 if !x && y; and a value greater than 0 if x && !y
如果x == y,则返回0;如果!x && y,则返回负值;如果x && !y,则返回正值。

Since:
1.7

logicalAnd
public static boolean logicalAnd(boolean a, boolean b)
Returns the result of applying the logical AND operator to the specified boolean operands.
返回对指定boolean操作数进行逻辑与运算的结果。

Parameters:
a - the first operand
b - the second operand
a - 第一个操作数。
b - 第二个操作数。

Returns:
the logical AND of a and b
a和b逻辑与的结果。

Since:
1.8
See Also:
BinaryOperator

logicalOr
public static boolean logicalOr(boolean a, boolean b)
Returns the result of applying the logical OR operator to the specified boolean operands.
返回对指定boolean操作数进行逻辑或运算的结果。

Parameters:
a - the first operand
b - the second operand
a - 第一个操作数。
b - 第二个操作数。

Returns:
the logical OR of a and b
a和b逻辑或的结果。

Since:
1.8
See Also:
BinaryOperator

logicalXor
public static boolean logicalXor(boolean a, boolean b)
Returns the result of applying the logical XOR operator to the specified boolean operands.
返回对指定boolean操作数进行逻辑异或运算的结果。

Parameters:
a - the first operand
b - the second operand
a - 第一个操作数。
b - 第二个操作数。

Returns:
the logical XOR of a and b
a和b逻辑异或的结果。

Since:
1.8
See Also:
BinaryOperator

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值