Considerations for the IF statement:

Source: Internet
Author: User

Considerations for the IF statement:

A: Comparing expressions whether simple or complex, the result must be a Boolean type

B:IF Statement Control Statement Body if it is a statement, curly braces can be omitted;

If it is more than one statement, you cannot omit it. Never omit the suggestion.

C: Generally speaking: there is no semicolon on the left curly brace, there is no left brace for the semicolon

Class Ifdemo {

public static void Main (string[] args) {

int x = 20;

if (x = = 20) {

System.out.println ("x equals 10");

}

if ((x > 5) | | (x = = 20)) {

System.out.println ("x is greater than or equal to 10");

}

System.out.println ("-------------------");

int a = 100;

/*

if (a = = 100) {

System.out.println (the value of "A is 100");

}

*/

if (A! = 100) {

System.out.println (the value of "A is 100");

System.out.println ("over");

}

System.out.println ("-------------------");

int b = 100;

if (b! = 100); Here is actually a statement body, but is an empty statement body.

code block

{

System.out.println (the value of "B is 100");

System.out.println ("over");

}

}

}


This article is from the "11250741" blog, please be sure to keep this source http://11260741.blog.51cto.com/11250741/1748074

Considerations for the IF statement:

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.