In Java, we utilize conditional statements to execute certain block of codes if the conditional statement is true it will execute that block of code or else it will either execute another conditional statement or execute the statement outside the conditional statements.
From the above paragraph already I gave you the answer of the type of conditional statement that we are going to use. That’s right we are going to use the “if-else statement”. “If-else statement” help the program to make certain decision and execute the block of code if the decision is correct. Let me now explain how the program reads your if-else statement.
if (conditional statement is true){
//Execute this block of code.
} else if( 2nd conditional statement is true){
/* if the 1st conditional statement is false, the program will go the next conditional statement to check if it is true. If it is the program will execute this block of code. */
}else{
// else execute this block of code if the above 2 conditional statement are false.}
When using conditional statements you need to make use of the comparison operators like “==” (equals to), “<” (lesser than), “>”(greater than), “<=” (lesser than or equals to), “>=”(greater than or equals to), “!=”(not equals to).
The image below is a snippet of a simple code:

Integer is a primitive data type means it has a special characteristics about the kind of data it handles and it is easy to manipulate data. Since, it is primitive we can make use of “==” to check is the 6 is equal to the data inside the variable. There are primitive data too which are boolean, float, double, short, char and bytes.
How about strings??? Strings are non-primitive data type and also known as object data types. Therefore, it has its own method to check if the variable is equal to the value or not. For example: if(gender.equals(“female”)) or gender.equalsIgnoreCase(“female”). “equals” and “equalsIgnoreCase” is a method of string. For more info: Link.
The image below is a snippet of a simple code:
