Logical Type

Java 基本型別 Primitive Data Types 種類

種類

型別
長度
值域
初值
使用建議
備註

boolean

true / false

false

X

範例

UsingBoolean.java
public class UsingBoolean {
       public static void main(String[] args) {

              boolean test = false;
              System.out.println("布林變數 test 的值:" + test);
              test = true;
              System.out.println("布林變數 test 的值:" + test);

       }
}
執行結果
布林變數 test 的值:false
布林變數 test 的值:true

最后更新于