Back In the print window choose "Save as PDF" as the destination
NOTE.CS

static and final in Java

1 topic · 28 Nov 2026
1

static and final in Java

Java
  • static variable — one copy for the whole class.
  • static method — called with the class name; cannot use this or instance members.
  • static block — runs once when the class loads.
  • final — constant variable, method that cannot be overridden, class that cannot be extended (e.g. String).
Java
class Config {
    static final double PI = 3.1416;   // constant
    static int instances;
    static { System.out.println("class loaded"); }
    Config() { instances++; }
}