Control Structures in Java

Posted on

Control structures:

Control structures are mostly used to control the flow of your program. Java provides the following control structures.

  • if statement: Allows you to check for conditions in your application.
    Syntax: –

    1. if(condition)
      statement;
    2. if(condition)
      {

      statements;

      }
      else
      if(condition)
      {

      statements;

      }
      else

 

/*A small demo on control structures*/

class App5{

public static void main(String yck[])
{

int x,y;
x=100;
y=20;
if (x>y)
System.out.println(“x is big”);
else
System.out.println(“y is big”);
}

}

 

output:
\>javac App5.java
\>java App5
x is big

Leave a Reply

Your email address will not be published. Required fields are marked *