0
Java Ternary operator explanation
Hi guys So I don’t get how to understand this code how can I know how to understand it properly Int= smallest (a<b)? (a<c?a:c) : (b<c?b:c); return smallest;
1 Resposta
+ 5
ternary operator is a short of if else statement.
int x = a > b ? a : b;
if (a > b)
x = a;
else
x = b;
So here
if (a < b) {
if (a < c)
smallest = a;
else
smallest = c;
} else {
if (b < c)
smallest = b;
else
smallest = c;
}