【发布时间】:2011-08-28 05:53:24
【问题描述】:
为什么private Boolean shouldDropTables;默认分配true给变量而不是NULL,就像写private Integer anInteger;时一样?
我之所以问,是因为我遇到了一些代码,其中对 shouldDropTables 布尔变量为 NULL 的评估或不确定是否执行方法。
【问题讨论】:
-
"为什么 private Boolean shouldDropTables; 默认情况下将 true 分配给变量而不是 NULL" 它没有。为此需要一些其他代码,此问题未显示。
-
这里的答案很好,但没有上下文和错误的假设。这个问题不是 SO 的主题