Tuesday 25 April 2017

Java if Statements ~ foundjava

Java if statements is used to execute some code, if a condition is true otherwise if condition is false, execute nothing.
Syntax:
if(condition)
{
    statement 1;
    statement 2;
    ...
}
java-if
Example:
public class Sample{

   public static void main(String args[]){
      int a=20, b=30;

      if(b>a)
         System.out.println("b is greater");
      }
}
Program Output:

java-if-statements

No comments:

Post a Comment