看过张老师的银行业务调度视频,其中ServiceWindow类中的start()方法,想直接往start()中赋值,但是switch报错,需要变成final类型,为什么呢?- public void start(CustomerType type) {
- Executors.newSingleThreadExecutor().execute(new Runnable() {
- public void run() {
- while (true) {
- switch (type) { //需要将type变为fianl
- case COMMON:
- commonService();
- break;
- case EXPRESS:
- expressService();
- break;
- case VIP:
- vipService();
- break;
- }
- }
- }
- });
- }
复制代码 |