Java 中的布林值是什麼?


布林值只表示兩個值 true 或 false。在 Java 中,值 1 被認為是 true,值 0 被認為是 false。

示例

線上演示

public class Test{
   public static void main(String args[]) throws Exception{
      boolean bool1 = true;
      boolean bool2 = false;
      boolean bool = (25==(100/4));

      System.out.println(bool1);
      System.out.println(bool2);
      System.out.println(bool);
   }
}

輸出

true
false
true

更新日期:2019 年 7 月 30 日

2K+ 次瀏覽

開啟你的 事業

完成課程獲得認證

開始
廣告
© . All rights reserved.