Boolean data type Booleanvariable is stored as8Bits (1bytes), but can only be a value ofTrueorFalse, it can be seen as a " switch " to use. Booleanthe value of the variable is displayed asTrueorFalse(In usePrinttime), or#TRUE #or#FALSE #(In useWrite #time). UseKey WordsTruewith theFalsecan beBooleanvariables are assigned to one of these two states. in theJavainBooleanvalue can only betrueand thefalse, but not with0and the1instead, and be sure to lower case. Boolean operatemeans thatBoolean Operations. In theAnsysSoftwarein his drop-down menu will prompt for a Boolean operation item. In some programming languages, this type of keyword isbool, such asC + +, the same usage.
For example: (for prime numbers)
public class Primeout {
public static void Main (String []args) {
/* Method of Judging primes: No integer can be found in the interval (1,X/2) to divide the prime number X
* The number is stored in an array to 5 outputs per line
*/
for (int i=2;i<=100;i++) {
Boolean flag=true;
for (int j=2;j<=i/2;j++) {
if (i%j==0) {
Flag=false;
Break
}
}
if (flag) {
System.out.print (i + "");
}
}
}}
Boolean data type