public static final int MAX_USERS = 1000;public static final String API_URL = "https://api.example.com";private static final List<String> ROLES = List.of("ADMIN", "USER");
Convention
Rule
Modifiers
public static final
Naming
UPPER_SNAKE_CASE
Initialization
At declaration or in static block
5. Understanding Variable Shadowing
Scenario
Behavior
Local hides field
Use this.field
Subclass hides static field
Use Super.field
Inner class hides outer
Use OuterClass.this.field
6. Using Static Variables
Example: Static counter
class Counter { private static int totalInstances = 0; Counter() { totalInstances++; } static int getCount() { return totalInstances; }}