Java Reference
In-Depth Information
one argument of type
int
, that can satisfy both abstract method specifications, because
the one in interface
Colorable
requires the same method to return no value, while the
A class type should be declared
abstract
only if the intent is that subclasses can be cre-
ated to complete the implementation. If the intent is simply to prevent instantiation
arguments, make it
private
, never invoke it, and declare no other constructors. A class
of this form usually contains class methods and variables.
The class
Math
is an example of a class that cannot be instantiated; its declaration looks
like this:
public final class Math {
private Math() { } // never instantiate this class
. . . declarations of class variables and methods . . .
}
8.1.1.2. final Classes
A class can be declared
final
if its definition is complete and no subclasses are desired or
required.
another class declaration; this implies that a
final
class cannot have any subclasses.
It is a compile-time error if a class is declared both
final
and
abstract
, because the implement-
Because a
final
class never has any subclasses, the methods of a
final
class are never over-
ridden (§
8.4.8.1
).
8.1.1.3. strictfp Classes
The effect of the
strictfp
modifier is to make all
float
or
double
expressions within the class de-
claration (including within variable initializers, instance initializers, static initializers, and
constructors) be explicitly FP-strict (§
15.4
).
This implies that all methods declared in the class, and all nested types declared in the class,
are implicitly
strictfp
.
8.1.2. Generic Classes and Type Parameters