java lang包下boolane类

开这个文集 发布java jdk所为常用的java code api 从java lang 下开始

会尽快完善这个文集
S.N. 构造函数和说明
1 Boolean(boolean value)
This allocates a Boolean object representing the value argument.这分配一个布尔值参数的对象。
2 Boolean(String s)
这分配一个表示true值Boolean对象的字符串参数不为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());
    //静态办法取得 w为flase 在 字符串为true 返回值才为 true
    System.out.println(Boolean.getBoolean("w"));
    //以下三种情况均是静态方法 分别为 and or xor
    System.out.println(Boolean.logicalAnd(true, true));
    System.out.println(Boolean.logicalOr(false, true));
    System.out.println(Boolean.logicalXor(false, true));
    //静态转为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() {
    //构造方法一 初始化为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());
    //静态传入比较 flase
    System.out.println(Boolean.compare(false, true));
    }

}

···

你可能感兴趣的:(java lang包下boolane类)