BooleanTest.java
package sample;
public class BooleanTest
{ public static void main(String[] args) { //定义b1的值为true boolean b1 = true; //定义b2的值为false boolean b2 = false; //使用boolean类型的值和字符串进行连接运算,boolean类型的值会自动转换成字符串 String str = true + ""; //下面将输出true System.out.println(str); } }输出:
true