This table (matrix) shows which modifier to which element can be applied.
See a matrix of the Protection Modifiers in Java - how they set the visibility and the access rights.
element | Data field | Method | Constructor | Class | Interface | ||
---|---|---|---|---|---|---|---|
modifier | top level (outer) |
nested (inner) |
top level (outer) |
nested (inner) |
|||
abstract | no | yes | no | yes | yes | yes | yes |
final | yes | yes | no | yes | yes | no | no |
native | no | yes | no | no | no | no | no |
private | yes | yes | yes | no | yes | no | yes |
protected | yes | yes | yes | no | yes | no | yes |
public | yes | yes | yes | yes | yes | yes | yes |
static | yes | yes | no | no | yes | no | yes |
synchronized | no | yes | no | no | no | no | no |
transient | yes | no | no | no | no | no | no |
volatile | yes | no | no | no | no | no | no |
strictfp | no | yes | no | yes | yes | yes | yes |
abstract void method();
native void method();