A boolean data type with true or false values:
boolean isJavaFun = true;
boolean isFishTasty = false;
System.out.println(isJavaFun); // Outputs true
System.out.println(isFishTasty); // Outputs false
The boolean
keyword is a data type that can only take the values true
or false
.
Boolean values are mostly used for conditional testing (read the Java Booleans Tutorial for more information).
Read more about data types in our Java Data Types Tutorial.
Read more about booleans in our Java Booleans Tutorial.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!