Java Ternary operator associativity demo
Copy this code and paste it in your HTML
public class TernaryOp {
public static void main
(String[] args
) { // switch case with ternary op idiom:
i == 1 ? "one"
: i == 2 ? "two"
: i == 3 ? "three"
: "too many!"
);
}
}
Report this snippet
Comments
Subscribe to comments