import lombok.extern.slf4j.Slf4j;import org.junit.Test;@Slf4jpublic class SwitchTest { @Test public void givenByte_then() { Byte flag = 1; switchMethod(flag); flag = 2; switchMethod(flag); flag = 3; switchMethod(flag); } /** * 如果switch表达式是Byte类型, * case后面的数字也会自动转型为Byte类型 * * @param flag */ private void switchMethod(Byte flag) { switch (flag) { case 1: log.info("is 1"); break; case 2: log.info("is 2"); break; default: log.info("not match. value:" + flag); } log.info("success:" + flag); }}