In Java, can a static variable be anything other than a static class variable? It seems the qualifier class is not strictly necessary when referring to static variables, other than to be super clear.
From the Java Language Specification, on fields
A static field, sometimes called a class variable, is incarnated when the class is initialized (§12.4).
They're one and the same.
There's one kind of field that can be static and isn't associated with a class: interface constants, which are both static and final (and therefore not exactly a "variable", since they don't vary).
You can use them even without initializing an implementation of the interface, so they're not necessarily associated with a class at all. I believe they're initialized when the interface is used.
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