Java Reference
In-Depth Information
You specify a single static member name to import only that name:
import static java.lang.Math.PI; // Import the PI static
field only.
import static java.lang.Math.cos; // Import the cos() stat-
ic method only.
In contrast, you specify the wildcard to import all static member names:
import static java.lang.Math.*;
// Import all static mem-
bers from Math.
You can ow refer to the static member(s) without having to specify the class name:
compilertoreporterrors.Forexample,supposeyour geom packagecontainsa Circle
class with a static member named PI . ow suppose you specify import static
java.lang.Math.*; and import static geom.Circle.*; at the top of
yoursourcefile.Finally,supposeyouspecify System.out.println(PI); some-
whereinthatfile'scode.Thecompilerreportsanerrorbecauseitdoesnotknowif PI
belongs to Math or Circle .
In an ideal world, othing bad ever happens when an application runs. For example, a
application needs to instantiate objects.
and require more memory than the JVM can provide. Your goal is to write code that
properly responds to these and other exceptional situations (exceptions).
at representing exceptions in source code. It then examines the topics of throwing and
a method returns, whether or not an exception has been thrown.
Search WWH ::

Custom Search