Java-Simple If Statement

Simple If Statement

The if statement enables us to take decisions based on a condition. Such a condition is expressed in the form of a relational expression or a logical expression. The value of a relational or logical expression is always one of the two logical constants, namely, true and false. If the value of the relational or logical expression involved in an if statement is true, one action is taken. Here is the correct syntax of the if statement:

The ‘statement-block‘ may be a single statement or a group of statements. If the test expression is true, the statement-block will be executed; otherwise the statement-block will be skipped.



Program Source

class Javaapp {

    public static void main(String[] args) {
            System.out.println("50 Greater than 20 is true");

Leave a Comment