Link to home
Start Free TrialLog in
Avatar of just23
just23Flag for Ireland

asked on

if else statement

My question is why output is 3 and not 2 as I expected?

public class CheckNumber{

public static void main(String []args){
int i = 0;
int j = 0;

if (i > 10)
      j = 1;
else if (i == 0)
      if (j == 100)
      j = 2;
      else
            j = 3;
      else
            j = 4;
                  
      System.out.println(j);
      }
}
SOLUTION
Avatar of jackDOTisenberg
jackDOTisenberg
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of just23

ASKER

I got it. thanks a lot lads