Home  >  Article  >  Java  >  What does if in java mean?

What does if in java mean?

(*-*)浩
(*-*)浩Original
2019-11-15 09:54:204076browse

If in Java is the guide word of a conditional statement. An if statement contains a Boolean expression and one or more statements. The if keyword indicates conditional execution of a block of code. The condition must evaluate to a Boolean value.

What does if in java mean?

##Grammar

The syntax of the if statement is as follows: java course)

if(布尔表达式)
{
   //如果布尔表达式为true将执行的语句
}

If the value of the Boolean expression is true, the code block in the if statement is executed, otherwise the code after the if statement block is executed.

The if statement is used to determine whether the given condition is met, and one of the two operations given is executed based on the result of the determination (true or false).

The return value of if is true or false, which can be stored in a bool variable and occupies one byte.

Test.java file code:

public class Test {
 
   public static void main(String args[]){
      int x = 10;
 
      if( x < 20 ){
         System.out.print("这是 if 语句");
      }
   }
}

The above code is compiled and run and the results are as follows:

这是 if 语句

The above is the detailed content of What does if in java mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn