
The java.lang.Boolean class is a final class and it is a subclass of Object class. The Boolean class wraps the value of primitive datatype boolean into a Boolean object. An object of type Boolean contains a single field whose type is boolean. In other words, the wrapper classes create objects for primitive data types. This class provides many methods for converting a boolean to a String and a String to a boolean as well as other constants and methods useful when dealing with a boolean.
网站模板是能够具有交互性,能够包含更多活跃的元素,就有必要在网页中嵌入其它的技术。如:Javascript、VBScript、Document Object Model(DOM,文档对象模型)、Layers和 Cascading Style Sheets(CSS,层叠样式表),这里主要讲Javascript。那么Javascript是什么东西?Javascript就是适应动态网页制作的需要而诞生的
70
<strong>public final class Boolean extends Object implements Serializable, Comparable</strong>
public class BooleanTest {
public static void main(String[] args) {
Boolean b;
b = new Boolean(true);
boolean b1;
b1 = b.booleanValue();
String data = "The Primitive value of Boolean object " + b + " is " + b1;
System.out.println(data);
}
}The Primitive value of Boolean object true is true
public class BooleanTest1 {
public static void main(String args[]) {
Boolean b1, b2;
b1 = new Boolean(true);
b2 = new Boolean("false");
System.out.println("b1 Value is : "+ b1.booleanValue());
System.out.println("b2 Value is : "+ b2.booleanValue());
System.out.println("b1 compareTo b2 : "+ b1.compareTo(b2));
System.out.println("b1 equals b2 : "+ b1.equals(b2));
}
}b1 Value is : true b2 Value is : false b1 compareTo b2 : 1 b1 equals b2 : false
以上就是Boolean类在Java中的重要性是什么?的详细内容,更多请关注php中文网其它相关文章!
java怎么学习?java怎么入门?java在哪学?java怎么学才快?不用担心,这里为大家提供了java速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号