開這個文集 發(fā)布java jdk所為常用的java code api 從java lang 下開始
會盡快完善這個文集
S.N. 構(gòu)造函數(shù)和說明
1 Boolean(boolean value)
This allocates a Boolean object representing the value argument.這分配一個布爾值參數(shù)的對象。
2 Boolean(String s)
這分配一個表示true值Boolean對象的字符串參數(shù)不為null,是平等的,忽略大小寫字符串“true”。
code
···
package core.java.lang;
/**
@author DGW
@date 2017 2017年4月13日 下午4:39:33
-
@filename BooleanClass.java
*/
public class BooleanClass {public static void main(String[] args) {
//通過字符串初始化為 flase
Boolean bool=new Boolean("1");
//為flase
System.out.println(bool.booleanValue());
//靜態(tài)辦法取得 w為flase 在 字符串為true 返回值才為 true
System.out.println(Boolean.getBoolean("w"));
//以下三種情況均是靜態(tài)方法 分別為 and or xor
System.out.println(Boolean.logicalAnd(true, true));
System.out.println(Boolean.logicalOr(false, true));
System.out.println(Boolean.logicalXor(false, true));
//靜態(tài)轉(zhuǎn)為true值
System.out.println(Boolean.parseBoolean("true"));
//valueof 返回一個boolean值
System.err.println(Boolean.valueOf(true));
System.out.println(Boolean.valueOf("1"));}
private static void M1() {
//構(gòu)造方法一 初始化為true
Boolean bool=new Boolean(Boolean.TRUE);
//取得布爾值 true
System.out.println(bool.booleanValue());
//比較獲得值 為true
System.out.println(bool.compareTo(Boolean.TRUE));
//比較值情況 字符串必須這樣做 返回 flase
System.out.println(bool.equals(Boolean.FALSE));
//得到hash值
System.out.println(bool.hashCode());
//返回true
System.out.println(bool.toString());
//靜態(tài)傳入比較 flase
System.out.println(Boolean.compare(false, true));
}
}
···