Home » Java Basics » if/else statement

if/else statement

Compare integers

With this example we are going to demonstrate how to compare integers. The comparation between two integers can be performed using the greater than and less than symbols. In short, to compare two integers i1 and i2 you should: Check if i1 is greater than i2 in an if statement. If it is true, that means that i1 is greater ...

Read More »

Simple if else Java Example

In this post, we feature a simple if else Java Example. The Java if statement is used to test a boolean condition i.e. true or false. 1. Introduction The logic inside the if condition executes when the condition is true otherwise the else block is executed. Java supports various types of if statements. if statementif else statementif else if statementnested ...

Read More »

Simple if statement

In this example we shall show you how to use a simple if statement. The if-else statement is the most basic of all the control flow statements. It tells your program to execute a certain section of code only if a particular expression evaluates to true. To use a simple if statement one should perform the following steps: Create a new boolean ...

Read More »