+ 8
How do you read this condition involving ternary operators?
a>b?a>c?a:c:b>c?b:c
7 Réponses
+ 7
if a>b
if a>c
return a
else
return c
else
if b>c
return b
else
return c
Hope this is more comprehensible : )
+ 7
Ipang Thank you! Your explanation helped.
+ 3
You're welcome silentlearner, glad it helps : )
+ 2
I would read it from left to right, looking at the colons to see where the next statement ends.
a>b?(a>c?a:c):(b>c?b:c);
But in real code rather use if/else like Ipang posted. Otherwise it is too confusing to read and understand for others, as you noticed.
+ 1
int X=2, int y=5;
result =x_ _?
system.out.println();
+ 1
Ratnakar rockzz please move your question into your own thread, posting a different question being irrelevant with original question here is not nice, Thanks for understanding : )
0
int X=2, int y=5;
int result =x_ _;
system.out.println();
plz tell me the fill in the blanks