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: