if else control statements java code example
Example 1: if statement in java
int x = 3;
if (x<=3){
System.out.println("Hello World");
}
else {
System.out.println("Bye World");
}
Example 2: java if else if ladder
import java.io.*;
class GFG {
public static void main(String[] args)
{
int i = 20;
if (i == 10)
System.out.println("i is 10\n");
else if (i == 15)
System.out.println("i is 15\n");
else if (i == 20)
System.out.println("i is 20\n");
else
System.out.println("i is not present\n");
System.out.println("Outside if-else-if");
}
}