Java-if-statement-in-java

提供:Dev Guides
移動先:案内検索

Javaのifステートメント

*if* ステートメントは、ブール式とそれに続く1つ以上のステートメントで構成されます。

構文

ifステートメントの構文は次のとおりです-

if(Boolean_expression) {
  //Statements will execute if the Boolean expression is true
}

ブール式がtrueと評価されると、ifステートメント内のコードブロックが実行されます。 そうでない場合、ifステートメントの終了後(閉じ中括弧の後)の最初のコードセットが実行されます。

流れ図

Ifステートメント

public class Test {

   public static void main(String args[]) {
      int x = 10;

      if( x < 20 ) {
         System.out.print("This is if statement");
      }
   }
}

これは、次の結果を生成します-

出力

This is if statement.