Java Boolean類中常見方法
//Boolean類中常見方法
public class BooleanMethod{
public static void main(String[] args) {
String str = new Boolean(true).toString();//返回字符串為"true"的String對(duì)象
Boolean b1 = Boolean.parseBoolean(str); //返回〗0.01 的Boolean對(duì)象
Boolean b2 = Boolean.valueOf("false"); //返回字符串為"false"的Boolean對(duì)象
int compareResult = Boolean.compare(b1,b2); //true和false比較,返回 1
System.out.print("String對(duì)象:"+ str);
System.out.println("返回 true 的 Boolean 對(duì)象:" + b1);
System.out.println("返回字符串為 false 的 Bnolean 對(duì)象:" + b2);
System.out.println("bl和b2的比較結(jié)果:"+ compareResult);
}
}
點(diǎn)擊加載更多評(píng)論>>