aboutsummaryrefslogtreecommitdiffstats
path: root/tests/features193/Switch1.java
blob: 1daeeff6fadf053cd70c4bf912a50fb401ad9b72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public class Switch1 {
	public static void main(String[] argv) {
		System.out.println(one(Color.R));
		System.out.println(one(Color.G));
		System.out.println(one(Color.B));
		System.out.println(one(Color.Y));
	}

	public static int one(Color color) {
		int result = switch(color) {
		case R -> 0;
		case G -> 1;
		case B -> 2;
		default -> 3;
		};
		return result;
	}
}

enum Color {
	R, G, B, Y;
}