-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCase.java
More file actions
17 lines (16 loc) · 709 Bytes
/
Case.java
File metadata and controls
17 lines (16 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import java.util.Scanner;
public class Case {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Fruit : ");
String fruit = input.next();
switch (fruit) {
case "Mango" -> System.out.println("king of fruit");
// if we don't put break after every case it will evaluate the next case also until it find break or default statement
case "Apple" -> System.out.println("Fruit of Kashmir");
case "Orange" -> System.out.println("Citrus Fruit");
case "Grape" -> System.out.println("Small fruit");
default -> System.out.println("Invalid input");
}
}
}