为什么有些方法不是用Groovy编译的?

blu*_*lue 0 groovy

为什么在方法B和C没问题的情况下不编译方法A?

class A {

  methodA() {

  }

  void methodB() {


  }

  static methodC() {


  }

}
Run Code Online (Sandbox Code Playgroud)

dar*_*ion 5

如果不声明方法的类型,则需要在groovy中使用"def"修饰符:

class A {
    def methodA() {
    }
}
Run Code Online (Sandbox Code Playgroud)

应该管用.