Your examples are all correct, however, they all share a common feature. The word static means that an enclosing instance is not necessary.
-
Only a static inner class can exist without an enclosing instance. For example, if you have a class
Fooand a non-static inner classBarthen you cannot create an instance ofBaroutside an instance ofFoo. -
A static method means you do not need an instance of the class to call the method. You can call
String.formatwithout an actualStringinstance for example. -
A static field will exist even without an instance of the class. If your
Fooclass has acounterfield that is static you can access it without ever instantiating an instance of theFooclass.
Consider, as a clarifying point, that an interface can have static classes, static fields, and static methods. However, it cannot have the non-static version of any of those things (ignoring default methods which are sort of ad-hoc’d into the concept). This is because you can never create an instance of an interface so there could never be an enclosing instance.
You can also declare inner interfaces, annotations, and enums to be static although the keyword in that case is entirely redundant (e.g. similar to declaring an interface method abstract). Interfaces, annotations, and enums have no relationship to an enclosing class to begin with so static can’t really take that away.
One last byzantine point. If you do a static import (import static pack.age.Foo.*) you will be able to make unqualified references to any static items in a class (including interfaces, annotations, and enums regardless of whether or not they are redundantly marked static).