A static class in Java is a nested (inner) class that is declared with the static modifier. It belongs to its enclosing class and can be accessed without creating an instance of the outer class. A static class cannot access non-static members of its outer class directly, as it does not depend on an instance of the enclosing class.
Example:
class OuterClass {
static class StaticClass {
void display() {
System.out.println(“This is a static class.”);
}
}
}
// Usage
OuterClass.StaticClass obj = new OuterClass.StaticClass();
obj.display();
Static classes are typically used for utility or helper classes and better organization.