Skip to Content
Java in a Nutshell, 5th Edition
book

Java in a Nutshell, 5th Edition

by David Flanagan
March 2005
Intermediate to advanced
1254 pages
104h 21m
English
O'Reilly Media, Inc.
Content preview from Java in a Nutshell, 5th Edition

Modifier Summary

As we’ve seen, classes, interfaces, and their members can be declared with one or more modifiers—keywords such as public, static, and final. Table 3-2 lists the Java modifiers, explains what types of Java constructs they can modify, and explains what they do. See also Section 3.1 and Section 3.2.1 earlier in this chapter, as well as Section 2.6.2 in Chapter 2.

Table 3-2. Java modifiers

Modifier

Used on

Meaning

abstract

Class

The class contains unimplemented methods and cannot be instantiated.

Interface

All interfaces are abstract. The modifier is optional in interface declarations.

abstract

Method

No body is provided for the method; it is provided by a subclass. The signature is followed by a semicolon. The enclosing class must also be abstract.

final

Class

The class cannot be subclassed.

Method

The method cannot be overridden (and is not subject to dynamic method lookup).

Field

The field cannot have its value changed. static final fields are compile-time constants.

Variable

A local variable, method parameter, or exception parameter cannot have its value changed. Useful with local classes.

native

Method

The method is implemented in some platform-dependent way (often in C). No body is provided; the signature is followed by a semicolon.

None (package)

Class

A non-public class is accessible only in its package.

Interface

A non-public interface is accessible only in its package.

Member

A member that is not

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java in a Nutshell, 8th Edition

Java in a Nutshell, 8th Edition

Benjamin J. Evans, Jason Clark, David Flanagan
Java in a Nutshell, 7th Edition

Java in a Nutshell, 7th Edition

Benjamin J. Evans, David Flanagan
Learning Java, 5th Edition

Learning Java, 5th Edition

Marc Loy, Patrick Niemeyer, Daniel Leuck
Learning Java, 4th Edition

Learning Java, 4th Edition

Patrick Niemeyer, Daniel Leuck

Publisher Resources

ISBN: 0596007736Supplemental ContentErrata Page