Java Reference
In-Depth Information
12
.
The method
hasNext
returns the value
true
if there is an input (token) in
the input stream, otherwise it returns
false
.
13
.
In the Windows console environment, the end-of-file marker is entered
using
Ctrl+z
. (Hold the
Ctrl
key and press
z
.) In the UNIX environ-
ment, the end-of-file marker is entered using
Ctrl+d
. (Hold the
Ctrl
key
and press
d
.)
14
.
In Java,
for
is a reserved word.
15
.
A
for
loop simplifies the writing of a counter-controlled
while
loop.
16
.
The syntax of the
for
loop is:
for
(initialize expression; logical expression; update expression)
statement
The
statement
is called the body of the
for
loop.
17
.
If you put a semicolon at the end of the
for
loop (before the body of the
for
loop), the action of the
for
loop is empty.
18
.
The syntax of the
do
...
while
statement is:
do
5
statement
while
(logical expression);
19
.
The
statement
is called the body of the
do
...
while
loop.
20
.
The body of the
while
and
for
loops might not execute at all, but the
body of a
do
...
while
loop always executes at least once.
21
.
In a
while
or
for
loop, the loop condition is evaluated before executing
the body of the loop. Therefore,
while
and
for
loops are called pretest
loops.
22
.
In a
do
...
while
loop, the loop condition is evaluated after executing the
body of the loop. Therefore,
do
...
while
loops are called post-test loops.
23
.
Executing a
break
statement in the body of a loop immediately terminates
the loop.
24
.
Executing a
continue
statement in the body of a loop skips the loop's
remaining statements and proceeds with the next iteration.
25
.
When a
continue
statement executes in a
while
or
do
...
while
loop,
the update statement in the body of the loop might not execute.
26
.
After a
continue
statement executes in a
for
loop, the update statement is
the next statement executed.
Search WWH ::
Custom Search