Skip to content

Commit 0e6bf21

Browse files
committed
Gave meaningful class names to all classes in chapter.
1 parent 2059e31 commit 0e6bf21

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

source/ch8_filehandling.ptx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<code>
2424
import java.lang.Math;
2525

26-
public class Main {
26+
public class SquareRoot {
2727
public static void main(String[] args) {
2828
System.out.println(Math.sqrt(25));
2929
}
@@ -77,13 +77,13 @@
7777

7878

7979
<p>
80-
We will now create a <c>File</c> object. It is important to create a meaningful name for the <c>File</c> object. We will call ours <c>myFile</c>.
80+
We will now create a <c>File</c> object. It is important to create a meaningful name for the <c>File</c> object. We will call ours <c>myFile</c>. We will also call our class <c>CreateFile</c>
8181
</p>
8282

8383
<program xml:id="create-file-java" interactive="activecode" language="java" add-files="myfile-created">
8484
<code>
8585
import java.io.File;
86-
public class Main {
86+
public class CreateFile {
8787
public static void main(String[] args) {
8888
File myFile = new File("myfile.txt");
8989
System.out.println(myFile);
@@ -202,8 +202,9 @@
202202
<code>
203203
import java.io.File;
204204
import java.io.FileNotFoundException;
205-
import java.util.Scanner;public class Main {
206-
public static void main(String[] args) {
205+
import java.util.Scanner;
206+
public class ReadFile {
207+
public static void main (String[] args) {
207208
String filename = "myfile.txt";
208209
try (Scanner fileReader = new Scanner(new File(filename))) {
209210
while (fileReader.hasNextLine()) {
@@ -319,7 +320,7 @@
319320
<code>
320321
import java.io.File;
321322
import java.io.IOException;
322-
import java.util.Scanner;public class Main {
323+
import java.util.Scanner;public class WriteFile {
323324
public static void main(String[] args) {
324325
String filename = "myfile8-4-3.txt";
325326
try (Scanner reader = new Scanner(new File(filename))) {

0 commit comments

Comments
 (0)