elseif statement in java

In the previous post, we have seen if else statement. In this post, we will learn about elseif statements.

If we have multiple verification check points, we can use elseif statements. A if statements can be followed by zero or more elseif statements.

If there is a requirement to put else as well, then it must come after elseif statement.

Syntax of if ..else if:

Example of else if:

Output: It is a php book.


?: conditional operator:

It is a conditional operator which works same like a if..else statement. If condition is ture ,it returns value  that comes after ‘?’ , else it returns value after ‘:’.

Let’s understand with an example , where we are checking if book is a java book or PHP book.

Output: PHP book
Ask Question
If you have any question, you can go to menu ‘Features -> Q&A forum-> Ask Question’.Select the desired category and post your question.


Print Friendly, PDF & Email
if statement in java
switch case in java
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. He is an automation engineer having more than 8 years of experience who loves troubleshooting in automation and finding innovative ways to solve the problems. His other leisurely activities includes playing harmonica, paintings, sketching portrait, watching movies and travelling etc.

You may also like...

1 Response

  1. August 10, 2015

    […] the previous post, we have seen if..else if conditional statements. In this post, we will learn switch case […]