Java Reference
In-Depth Information
catching more errors at compile time. A
synchronized
statement provides basic object-level
monitor locking. A
try
statement can include
catch
and
finally
clauses to protect against non-
local control transfers.
Chapter 15
describes expressions. This document fully specifies the (apparent) order of
evaluation of expressions, for increased determinism and portability. Overloaded methods
and constructors are resolved at compile time by picking the most specific method or con-
structor from those which are applicable.
Chapter 16
describes the precise way in which the language ensures that local variables are
definitely set before use. While all other variables are automatically initialized to a default
value, the Java programming language does not automatically initialize local variables in
order to avoid masking programming errors.
Chapter 17
describes the semantics of threads and locks, which are based on the monitor-
based concurrency originally introduced with the Mesa programming language. The Java
programming language specifies a memory model for shared-memory multiprocessors that
supports high-performance implementations.
Chapter 18
presents a syntactic grammar for the language.
1.2. Example Programs
Most of the example programs given in the text are ready to be executed and are similar in
form to:
class Test {
public static void main(String[] args) {
for (int i = 0; i < args.length; i++)
System.out.print(i == 0 ? args[i] : " " + args[i]);
System.out.println();
}
}
On a machine with the Oracle JDK installed, this class, stored in the file
Test.java
, can be
compiled and executed by giving the commands:
javac Test.java
java Test Hello, world.
producing the output:
Hello, world.