在封闭范围中定义的局部变量a必须是最终的或有效的最终

时间:2017-07-03 12:44:55

标签: java

@Test
public void test() throws IOException{
    int a = 5;
    Pipe pipe = Pipe.open();
    new Thread(new Runnable(){
        @Override
        public void run() {
            pipe.sink();
            a++;
        }
    }).start();
}

为什么a++报告错误:

  

在封闭范围内定义的局部变量a必须是final或   有效的最终

但是pipe.sink()没有? 我使用的是jdk8.0

0 个答案:

没有答案
相关问题