Confusing If Else Output program in java




Confusing If Else Output program in java >
public class ConfusingIfElseOutput {
    public static void main(String[] args) {
          int num=3;
          if (num >= 0)
          if (num == 0)
          System.out.println("first");
          else 
          System.out.println("second");
          else
          System.out.println("third");
         
    }
} 



//We have used confusing if else
//output = second


If we format above program will look like this >
//Second if is inside first if.


int num = 3;
if (num >= 0)
    if (num == 0)
          System.out.println("first");
    else
          System.out.println("second");
else
    System.out.println("third");


Having any doubt? or you you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.

Related >





eEdit
Must read for you :