对于Boolean类使用了字符串构造方式,并且之后使用了toString()方法将true和false以字符串形式输出。
/**
* 对于Boolean类使用了字符串构造方式,并且之后使用了toString()方法将true和false以字符串形式输出。
* @author HAN
*
*/
public class BooleanApps {
Boolean b1=new Boolean("true");
String str1= b1.toString();
Boolean b2=new Boolean("OK");
String str2= b2.toString();
public BooleanApps(){
System.out.println(str1);
System.out.println(str2);
}
public static void main(String[] args){
new BooleanApps();
}
}
本文通过示例展示了如何使用字符串构造方式实例化 Java 中的 Boolean 类,并使用 toString() 方法将布尔值转换为字符串形式输出。示例中创建了两个 Boolean 对象 b1 和 b2,并分别用 true 和 OK 初始化。
1804

被折叠的 条评论
为什么被折叠?



