Skip to main content

If else question

1 reply [Last post]
lupusolus
Offline
Joined: 2006-02-17
Points: 0

Hi, I'll keep this brief. My if else if else if else statement might change a value of a variable which is checked in the second line. I want it to affect the execution of the third line; in other words, does java break out of the entire statement once one condition is true, or does it check every statement in sequence. Thanks!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ojfoggin
Offline
Joined: 2006-02-14
Points: 0

Hi

If you have more than one if statement and you want it to check all of them then you can remove the else.
eg
if()
{
}
else if()
{
}

becomes
if()
{
}
if()
{
}

That way if something is true for both ifs then both method will be applied.