16 lines
310 B
Java
16 lines
310 B
Java
import java.util.*;
|
|
|
|
public class TernaryOperator {
|
|
public static void main(String[] args) {
|
|
int x = 10;
|
|
int y = (x > 5) ? 100 : 200;
|
|
}
|
|
|
|
public static void nestedTernaryOperator() {
|
|
int x = 10;
|
|
int y = 20;
|
|
int z = (x > 5) ? (y > 10 ? 30 : 40) : 50;
|
|
}
|
|
|
|
}
|