Added switch and ternary operators in java

This commit is contained in:
Mayank Agarwal
2023-01-30 00:15:04 +05:30
parent f040615faf
commit c518f76628
2 changed files with 62 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
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;
}
}