Advertisement



< 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.






Note:





Advertisement




Java - if statement example


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

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


if(2>4)
{
	System.out.println("2 is greater than 4");
}


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


}
}


Output is -


100 is greater than 5
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




Advertisement

Notifications



Please check our latest addition

PYTHON and DJANGO


Advertisement