Skip to content

Commit 4727ea1

Browse files
authored
Merge pull request #361 from habibasorour/issue_356_listing
Issue 356 fixed 9. 5 isting
2 parents f245fe6 + 53bf752 commit 4727ea1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

source/ch9_commonmistakes.ptx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
<p>
149149
Unlike Python, where you can create a new object without explicitly using a keyword, Java requires the <c>new</c> keyword to instantiate a new object.
150150
</p>
151+
<listing xml:id="new-keyword-error">
151152
<program language="java" interactive="activecode" line-numbers="yes">
152153
<code>
153154
// Histo.java // The filename for this example
@@ -164,8 +165,9 @@
164165
} // End of class
165166
</code>
166167
</program>
168+
</listing>
167169
<p>
168-
This error message occurs when you forget to use the <c>new</c> keyword to instantiate an object.
170+
The error message in <xref ref="new-keyword-error" text="type-global"/> occurs when you forget to use the <c>new</c> keyword to instantiate an object.
169171
Specifically, on line 8 of <c>Histo.java</c>, <c>data = Scanner(new File("test.dat"));</c> leads to a 'cannot find symbol' error.
170172
While the message states 'symbol: method Scanner(File)', this can be misleading.
171173
Java incorrectly interprets <c>Scanner()</c> as an attempt to call a static method named <c>Scanner</c> within the <c>Histo</c> class

0 commit comments

Comments
 (0)