(^220) | File Objects and Looping Statements
System.out.println(lineThree);
// Write three lines to outFile in reverse order
outFile.println(lineThree);
outFile.println(lineTwo);
outFile.println(lineOne);
outFile.close(); // Finished writing
}
}
Here are the input file, output file, and screen:
File infile.dat: File outfile.dat:
On System.out:
5.2 Looping
In Chapter 4, we introduced a statement that allows us to explicitly change the order in
which statements execute within a method. With this strategy, the flow of control within a
method can differ from the physical order of the statements. The physical orderis the order
T
E
A
M
F
L
Y
Team-Fly®