< Prev
Next >

If Statement

In Java, an If statement is used when we want to test a condition, which is evaluated for a boolean value - true or false.

Java - if statement example

//Java - if statement program
public class A
public static void main(String... ar)
	System.out.println("100 is greater than 50");

	System.out.println("50 is less than 100");
	System.out.println("Second statement to execute");

System.out.println("2 is greater than 4");

System.out.println("Statement outside If Statement"); //not associated with any if block


Output is -

100 is greater than 50
50 is less than 100
Second statement to execute
Statement outside If Statement

Program Analysis

Please Subscribe

Please subscribe to our social media channels for daily updates.

Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page


Please check our latest addition