Java Reference
In-Depth Information
•
(string)
9)
•
(string)
"10"
5.
The file name
String
should use
/
or
\\
instead of
\
. The
\
is used to create
escape sequences, and
\\
represents a literal backslash. The correct
String
is
Scanner input = new Scanner(new File("C:/temp/new
files/test.dat"));
6.
(a)
"numbers.dat"
or
"C:/Documents and Settings/amanda/
My Documents/numbers.dat"
.
(b)
"data/homework6/input.dat"
or
"C:/Documents and Settings/
amanda/My Documents/programs/data/homework6/input.dat"
.
(c) There is only one legal way to refer to this file: by its absolute path,
"C:/Documents and Settings/amanda/My Documents/homework/
data.txt"
.
7.
(a)
"names.txt"
or
"/home/amanda/Documents/hw6/names.txt"
.
(b)
"data/numbers.txt"
or
"/home/amanda/Documents/hw6/data/
numbers.txt"
.
(c) There is only one legal way to refer to this file: by its absolute path,
"/home/amanda/download/saved.html"
.
8.
input: 6.7 This file has
input: several input lines.
input:
input: 10 20 30 40
input:
input: test
6 total
9.
input: 6.7
input: This
input: file
input: has
input: several
input: input
input: lines.
input: 10
input: 20
input: 30
input: 40
input: test
12 total
10.
•
Using
hasNextInt
and
nextInt
:
0 total
Search WWH ::
Custom Search