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 statement

This is an example of how to use a simple if-else 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 test evaluates to true. Using a simple if-else statement to check in a boolean variable implies that you should: Create ...

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 »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns