You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/ch2_firstjavaprogram.ptx
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,8 @@
8
8
<title>Classes and Objects</title>
9
9
10
10
<p>
11
-
<idx>Object-Oriented Programming (OOP)</idx>
12
-
Depending on how deep your knowledge of Python and programming in general is, you may or may not be familiar with classes and objects. These two important <term>Object-Oriented Programming (OOP)</term> concepts will briefly be discussed. If you already have a good understanding of classes and objects in Python, this section may be skipped.
Depending on how deep your knowledge of Python and programming in general is, you may or may not be familiar with classes and objects. These two important <term>Object-Oriented Programming</term> (<term>OOP</term>) concepts will briefly be discussed. If you already have a good understanding of classes and objects in Python, this section may be skipped.
Copy file name to clipboardExpand all lines: source/ch3_javadatatypes.ptx
+22-12Lines changed: 22 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -728,18 +728,28 @@ main()
728
728
This program reads the file <c>alice30.txt</c> (which follows), and it then splits it into a list of words. Next it creates a dictionary called <c>count</c> which maps each word to the number of times that word occurs in the text. Finally, it prints out the words in alphabetical order along with their frequency.
The conditionals used in the if statement can be <term>Boolean variables</term>, <term>simple comparisons</term>, and <term>compound Boolean expressions</term>.
394
394
</p>
395
395
396
396
<p><idx>ternary operator</idx>
@@ -408,7 +408,7 @@ of an assignment statement. The following table summarizes how this works:
408
408
</row>
409
409
<row>
410
410
<cell><c>condition</c></cell>
411
-
<cell>The Boolean expression that is evaluated (e.g., <c>a % 2 == 0</c>).</cell>
411
+
<cell>The <c>boolean</c> expression that is evaluated (e.g., <c>a % 2 == 0</c>).</cell>
Copy file name to clipboardExpand all lines: source/ch8_filehandling.ptx
+5-3Lines changed: 5 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -85,6 +85,7 @@
85
85
<sectionxml:id="creating-files">
86
86
<title>Creating Files</title>
87
87
88
+
88
89
<p>
89
90
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>.
90
91
</p>
@@ -111,8 +112,9 @@
111
112
</p>
112
113
</note>
113
114
115
+
114
116
<p>
115
-
Now that we have created a new <c>File</c> object, we can create a file using the <c>createNewFile()</c> method from the <c>File</c> class. While the previous line of code creates an object within the program for the file, this method actually does the work of creating a file and saving it in the current working directory. This method returns a boolean value. If the method returns <c>true</c>, the file was successfully created. If the method returns <c>false</c>, there is already a file using the chosen file name. We can use this method's possible return values in tandem with an try/catch structure to determine if the file was created, or catch the error if a file with that file name already exists in the directory.
117
+
Now let's learn how to make a file in Java. In Python. files can be made using the <c>open()</c> function on a file path that doesn't exist yet. Similarly, in Java you create a file by using the <c>createNewFile()</c> method on a <c>File</c> object. This method actually does the work of creating a file and saving it in the current working directory, and returns a boolean value of either true or false if the file is successfully created. We can use this method's possible return values in tandem with an try/catch structure to determine if the file was created, or catch the error if a file with that file name already exists in the directory.
116
118
</p>
117
119
118
120
<p>
@@ -408,15 +410,15 @@
408
410
</note>
409
411
410
412
<p>
411
-
Speaking of overwriting data, what if we want to append text to the end of any text already in <c>myfile.txt</c>? To accomplish this, we can pass a boolean argument along with the file name when creating a new data argument:
413
+
Speaking of overwriting data, what if we want to append text to the end of any text already in <c>myfile.txt</c>? To accomplish this, we can pass a <c>boolean</c> argument along with the file name when creating a new data argument:
Now, when we use <c>write()</c> method like before, the text will be appended if there is already text in the document. If we were to update our code to include the boolean argument:
421
+
Now, when we use <c>write()</c> method like before, the text will be appended if there is already text in the document. If we were to update our code to include the <c>boolean</c> argument:
0 commit comments