public class PrimitiveSwitch { static String httpFamily(int status) { return switch (status) { case 200 -> "OK"; case int i when i >= 200 && i < 300 -> "other success " + i; case int i when i >= 400 && i < 500 -> "client error " + i; case int i -> "something else " + i; }; } static String flag(boolean b) { return switch (b) { case true -> "yes"; case false -> "no"; }; } static String big(long n) { return switch (n) { case 0L -> "zero"; case 1L -> "one"; case long l -> "many (" + l + ")"; }; } public static void main(String[] args) { System.out.println(httpFamily(200) + " | " + httpFamily(204) + " | " + httpFamily(404) + " | " + httpFamily(500)); System.out.println(flag(true) + " " + flag(false)); System.out.println(big(0) + " " + big(1) + " " + big(Long.MAX_VALUE)); } }