我讀這樣的: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
有關Groovy關閉的聲明說明。
而且我想,這是怎麼真實,在Java中,如果你有一個實例方法,當調用該方法,然後他們是如何說上面只執行的代碼虛擬機一看到它就執行它? 如果我有一個方法func(){int a =5; return a+5;}
,只有當我的理解被調用時纔會執行此操作。