JAVA condition: An introduction
A JAVA condition is needed when we want to make a decision between two
or more options in our program.
This happens when we have some processing which depends on some JAVA condition
to be executed. Otherwise, it will not be executed.
Imagine that our processing is to show a dialog to a student which
informs him/her if he/she passed the Exam or not.
Here we have two cases:
- Case 1: the student passed the exam. The average
of his correct answers is more than 50% (or equal 50%).
- In this case, we will display the success
message
- Case 2: the student failed in the exam. The
average of his correct answers is less than 50%.
- In this case, we will display the failure
message
So, the processing depends on the average of correct answers got by the
student.
To make sure that we display the right message in the right situation,
we should compare that average with 50 and do the processing according to the
result of that comparison.
The JAVA language, like most of programming languages, implements conditions
through control flow statements:
Please, click on the links to get into the details of each JAVA
condition statement.
Please, make sure to follow us on Facebook to get our latest Core JAVA tutorials.
Post a Comment