Java布尔原语

示例

阿boolean可以存储两个值中的一个,任一true或false

boolean foo = true;
System.out.println("foo = " + foo);                // foo = true

boolean bar = false;
System.out.println("bar = " + bar);                // bar =假

boolean notFoo = !foo;
System.out.println("notFoo = " + notFoo);          // notFoo =假

boolean fooAndBar = foo && bar;
System.out.println("fooAndBar = " + fooAndBar);    // fooAndBar = false

boolean fooOrBar = foo || bar;
System.out.println("fooOrBar = " + fooOrBar);      // fooOrBar = true

boolean fooXorBar = foo ^ bar;
System.out.println("fooXorBar = " + fooXorBar);    // fooXorBar = true

的默认值boolean是假的

boolean defaultBoolean;    // defaultBoolean ==否