我正在读这个:A closure looks a lot like a regular Java or Groovy code block, but actually it's not the same. The code within a regular code block (whether its a method block, static block, synchronized block, or just a block of code) is executed by the virtual machine as soon as it's encountered. With closures the statements within the curly brackets are not executed until the call() is made on the closure. In the previous example the closure is declared in line, but it's not executed at that time. It will only execute if the call() is explicitly made on the closure
我在想,这是怎么回事,在Java中,如果你有一个实例方法,代码只在调用该方法时执行,那么他们怎么说上面的VM一看到它就执行?如果我有一个方法func(){int a =5; return a+5;}
,我的理解是只有在调用时才会执行。