You are on page 1of 2

If statement in java programing.

<a href=”https://www.teeztareen.com/2019/06/if-statement-in-java-programing.html”> if
statement in java programing </a>

If statement is a keyword in java programming.if statement is a decision-making statement in


java programming.it is the simplest form of the selection constructs. It is used to execute and
skip the statement a set of a statement by checking condition.The condition is given as
relational expression. If the condition is true the statement a set of statements execute after
the if statement is executed.if condition is false the statement or set of statement after if the
statement is executed.The preceding program displays a message such as 6+2 is false if you
choose these answers it is wrong.You have used the selection statement to carry out the minor
change.This section introduced selection statement.java has several types of selection
statement but on this page, we study one way of the if statement.

Syntax of if statement.

If(condion)
{
Statement..1
Statement..2
Statement..3
}
example
If (radius>=0){
Area= radius*radius+pi
System.out.printin(“the area for the circle of radius “ +radius “is” area);}
Flowchart

Limitation of if statement.
If a statement is the simple selection structure but it is very limited in its use.
The statement or set of statement is executed if the condition is true but if the condition is the
false the nothing is happening.
A user may went for
Execute one statement or set of statement if the condition is true.
Execute the other statement and set of statement if the condition is false.

For example

Imort java.until.Scanner;
Public class SimpleDemo{
Public static void main(string[]args)
{
Scanner input= new scanner(system.in);
System.out.printin(“enter an integers:”);
Int number=input.nextint();
If(number%5==0)
System.out,printin(“hivi”)
If(number%2==0)
System.out.printin(“hivin”);
}}

Out put

<a href=”https://www.teeztareen.com/2019/06/if-statement-in-java-programing.html”> if
statement in java programing </a>

You might also like