Java Learning the third Boolean

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.