IF Statement in Java


The if statement is Java's conditional branch statement. It can be used to route program execution through two different paths. Here is the general form of the if statement.

Source Code

import java.util.Scanner;
 
public class if_statement {
    public static void main(String args[]) {
        int age;
        System.out.println("Enter Your Age : ");
        Scanner in = new Scanner(System.in);
        age=in.nextInt();
        if(age>=18)
        {
            System.out.println("You are Eligible For Vote...");
        }
    }
}
 
To download raw file Click Here

Basic Programs



Learn All in Tamil © Designed & Developed By Tutor Joes