Вы находитесь на странице: 1из 1

Restrictions on Local Classes

Local classes are subject to the following restrictions:


A local class is visible only within the block that defines it; it can never be used outside that block. Local classes cannot be declared public, protected, private, or static. These modifiers are for members of classes; they are not allowed with local variable declarations or local class declarations. Like member classes, and for the same reasons, local classes cannot contain static fields, methods, or classes. The only exception is for constants that are declared both static and final. Interfaces cannot be defined locally. A local class, like a member class, cannot have the same name as any of its enclosing classes.

Вам также может понравиться