Boolean is a Boolean value.
A Boolean value has only two values: True and False. Writing: True false.
So how do you use it?
The simplest usage:
class demo{ publicstaticvoid main (String [] args) { Scanner sc_input =new Scanner (system.in); System.out.println ("Please enter a number, this number will be compared with 100 by line"); double the_nub=sc_input.nextdouble (); Boolean BL=the_nub>100; // returns a value using the Boolean attribute System.out.println ("is this number greater than 100?") "+BL);
}
}
Detailed
Boolean bl=the_nub>100;
We know that = is an assignment operator, and the rule of operation is to assign the value of the right side of the operator to the left.
The Boolean only accepts two values, which is true and false.
That is, the right side returns the result of the the_nub>100 comparison.
And what is the result? Only two, greater than 100 returns true, and less than 100 returns false.
and Boolean values in the judgment, where the loop is more useful
Java Learning the third Boolean