I was wondering if static Initializer in Java as shown below is a closure which groovy built on to implement the language.
public class className{
static{
}
}
Thanks.
No. That is a block. Groovy also has these.
class A {
static {
println "static init block"
}
{
println "init block"
}
def closure = {
println "closure field"
}
}
a = new A()
The code above will print:
$ groovy Block.groovy
static init block
init block
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With