KnowledgeBoat Logo
|

Computer Applications

What is a compound statement? Give an example.

Input in Java

ICSE 2005

96 Likes

Answer

Two or more statements can be grouped together by enclosing them between opening and closing curly braces. Such a group of statements is called a compound statement.

if (a < b) {
            
    /*
    * All statements within this set of braces 
    * form the compound statement
    */

    System.out.println("a is less than b");
    a = 10;
    b = 20;
    System.out.println("The value of a is " + a);
    System.out.println("The value of b is " + b);
            
}

Answered By

49 Likes


Related Questions