Java 中的 boolean 和 Boolean 有什么区别? [英] What's the difference between boolean and Boolean in Java?
问题描述
我想了解 Java 中 Boolean
和 boolean
类型之间的区别,特别是它们与 GWT 相关的区别.我知道不支持这些方法,但如果可用,我想要更多信息.
I would like to understand the difference between the Boolean
and boolean
types in Java, specifically as they relate to GWT.
I know that methods are not supported but I want more info if it is available.
推荐答案
我不确定 GWT 因素是否有所不同,但总的来说:
I'm not sure if the GWT factor makes a difference but in general:
boolean 是 Java 原始类型,而 Boolean 是包装布尔值的对象/引用类型
boolean is a java primitive type whereas Boolean is an object/reference type that wraps a boolean
像这样在基元和对象之间进行转换称为装箱/拆箱.
Converting between primitives and objects like this is known as boxing/unboxing.
这里有更多信息:
http://javaeye.wordpress.com/2008/06/17/装箱和拆箱转换/
为什么要问盒子?
http://java.sun.com/j2se/1.5.0/docs/guide/language/autoboxing.html
http://www.javapractices.com/topic/TopicAction.do?id=197
这篇关于Java 中的 boolean 和 Boolean 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!