这是底层JVM的实现 JDK代码里面应该是看不到的 这是Boolean类里找出来的 /** * Returns a <tt>String</tt> object representing this Boolean's * value. If this object represents the value <code>true</code>, * a string equal to {@code "true"} is returned. Otherwise, a * string equal to {@code "false"} is returned. * * @return a string representation of this object. */ public String toString() { return value ? "true" : "false"; } /** * The value of the Boolean. * * @serial */ private final boolean value; 在进行和、与等操作时是使用的JVM进行处理的,你可以反编译JVM的代码 那就看得到了 呵呵
这要看具体的JVM的实现了
false由0整数表示
true用非零整数表示
而涉及boolean的操作会使用int
boolean数组用byte数组访问,但在堆里面,它可以表示为位域
看了Boolean的源代码,没发现int或byte,
boolean的源代码看不到
这是Boolean类里找出来的 /**
* Returns a <tt>String</tt> object representing this Boolean's
* value. If this object represents the value <code>true</code>,
* a string equal to {@code "true"} is returned. Otherwise, a
* string equal to {@code "false"} is returned.
*
* @return a string representation of this object.
*/
public String toString() {
return value ? "true" : "false";
}
/**
* The value of the Boolean.
*
* @serial
*/
private final boolean value;
在进行和、与等操作时是使用的JVM进行处理的,你可以反编译JVM的代码 那就看得到了 呵呵
boolean b;
b=false;声明一个boolean变量时,JVM有没有为它分配空间a?? false是以什么形式赋给b的?以什么形式存放的a??