Tutorialspoint examples

Learn java tutorial with examples for beginners online

If Else Statement in Java

If else statement is used to execute either of two block of statements depends upon the condition. If condition is true then if block will execute otherwise else block will execute.


   //Block of statements1.
   //Block of statements2.

Program to use if else statement in Java.

 * Program to use if else statement in Java program.
 * @author javawithease
public class IFELSEExample {	
	public static void main(String args[]){ 
		int num = 10;
		if(num == 10){
	          System.out.println("num is equals to 10.");
	          System.out.println("num is not equals to 10.");


num is equals to 10.

Download this example.

Download tutorialspointexamples Android App
Copyright © 2018 Tutorialspoint examples DMCA.com Protection Status