You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Switch2.java 527B

12345678910111213141516171819202122232425262728293031
  1. public class Switch2 {
  2. public static void main(String[] argv) {
  3. System.out.println(one(Color.R));
  4. System.out.println(one(Color.G));
  5. System.out.println(one(Color.B));
  6. System.out.println(one(Color.Y));
  7. }
  8. public static int one(Color color) {
  9. int result = switch (color) {
  10. case R -> 0;
  11. case G -> {
  12. int number4 = 8 / 2;
  13. yield number4 /4;
  14. }
  15. case B -> 2;
  16. default -> 3;
  17. };
  18. return result;
  19. }
  20. }
  21. enum Color {
  22. R, G, B, Y;
  23. }
  24. aspect X {
  25. int around(): call(* one(..)) {
  26. return proceed()*2;
  27. }
  28. }