static

A keyword marking a field or method as belonging to the class itself, so it can be used without creating an object.

In more detail

The main method is static so the JVM can call it before any object exists. A static field has one copy shared by the whole program. Static state is effectively global, so mutable static fields make code hard to test and unsafe to share between threads.

Example

static int value() { return 42; }

Related terms

Taught in

References

Certification courses