/*
If Else statement Example
This Java Example shows how to use if else statement in Java program.
*/
public class SimpleIfElseStatementExample {
public static void main(String[] args) {
/*
* If else statement is used to execute either of two conditions based
* upon certain condition.
* Syntax of if else statement is,
*
* if(<condition>)
* statement1
* else
* statement2
*
* where <condition> is a boolean expression.
* If <condition> is true, statement1 will be executed, else statement2 will
* be executed.
*/
int i = 0;
if(i == 0)
System.out.println("i is 0");
else
System.out.println("i is not 0");
}
}
/*
Output would be
i is 0
*/
Bookmark/Search this post with:
i love java
how to use if else statement by making a pingpong games.
hi there
uhmm...how can you compare 4 different statements using if else...that was exam yesterday... and i wasn't able to answer it...please help me...thanks a lot...the problem was.... making a program that would show numbers if they are odd or even and if they are negative or a positive odd/even number...the condition is...input a positive or negative number...numbers range from -100 to 0 and 0 to +100
Post new comment