Search code examples
javaif-statement

Will my program execute "else" even if it executed my "if"?


I'm wondering, if I have the following code:

v = 5;
if (v == 5) {
   v++;
}
else {
   //do something else
}

will my program "execute" the else part since my variable v is now different from 5?


Solution

  • No it will not execute the else statement if the if condition is satisfied