execution of conditional operator

I just wanted to know how actually the expression which has many conditional operators in it is executed..

e.g System.out.println(8>2?7<3?6>3?5:3:9:1);

I just wanted to know that here I have 2 conditions to be true ,so corresponding to it ,actually how the output would be generated,...

Replies

  • Sanyam Khurana
    Sanyam Khurana
    I think, it would be just like in case of nested if else statement. This would work as:
    System.out.println(8>2?7<3?6>3?5:3:9:1);
    => System.out.println(8>2?7<3?5:9:1);
    => System.out.println(8>2?9:1);
    => System.out.println(9);

    So, it would print 9! 😀

You are reading an archived discussion.

Related Posts

I just wanted to ask that is the runnable interface is implemented just so that the class can realise the concept of multiple inheritance ,because if our class extends thread...
Descriptions are superfluous: https://www.ba-bamail.com/Content.as...7nDOhAuOgGVeVroA7UqfrRJUc9NNRxaPrGJsT0=&d=294
i filled up everything but, after selecting examination center 1 , i cant select Choice of Examination City 2 and Choice of Examination City 3 , nothing shows when i...
Quote: One of the top medical device conferences - AdvaMed 2014 - concluded in Chicago, Wednesday and a few themes emerged around an industry that is witnessing seismic changes in...
Click Labs is privately held Information Technology and Services company founded by Samar Singla, Chinmay Agarwal, Parag Jain, Sanjay Dhakar and Rohit Goyal in the year 2011. Click Labs is...