Groovy closure is one of feature available on groovy. The function of this feature is like a method in java or any other programming language. We can modify variable, assign parameters or even manipulate a method. The differences between java method and groovy closure is :
1. Java method needs object initialization from the class that contain method we need. On the other hand, groovy doesn’t need that.
2. There is no visibility in groovy closure. But every single method in java must have visibility(public, private, protected).
3. There is differences in the way to write the code
Based on list above, actually we don’t have to worry about which one that we have to use in groovy, because we can use both of them whether java method or groovy closure. This is the sample code to use groovy closure.