Modifiers and Features
Not all modifiers can be applied to all features.
Top-level classes may not be protected.
Methods may not be transient.
Static can apply it to free-floating blocks of code.
Modifier | Class | Variable | Method | Constructor | Code Block |
---|---|---|---|---|---|
public | yes | yes | yes | yes | no |
protected | no | yes | yes | yes | no |
empty accessor | yes | yes | yes | yes | yes |
private | no | yes | yes | yes | no |
final | yes | yes | yes | no | no |
abstract | yes | no | yes | no | no |
static | no | yes | yes | no | yes |
native | no | no | yes | no | no |
transient | no | yes | no | no | no |
volatile | no | yes | no | no | no |
synchronized | no | no | yes | no | yes |
Home
Java Book
Class
Java Book
Class
Access Control:
- Access Control
- Member Access and Inheritance
- Class Member Access Protection and Package
- Modifiers and Features