In an Android example class theres this method:
static {
addItem(...);
}
When I reference the class, the items are indeed added. I never saw a method like this, a. how is this called and b. I suppose this method is called whenever the class is referenced (or the first time it is referenced)?
This is called static initializer
and the code inside it is invoked only once at class loading.
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