Skip to content

Commit f52b610

Browse files
nshizirungudieumerci@gmail.comnshizirungudieumerci@gmail.com
authored andcommitted
added listing tag to make the text more organized
1 parent 8590e3b commit f52b610

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
@@ -117,8 +117,9 @@
117117
<section xml:id="not-importing-a-class">
118118
<title>Not importing a class</title>
119119
<p>
120-
In Python, many classes are available by default. However, in Java, you must explicitly import most classes from external packages that you want to use.
120+
In Python, many classes are available by default. However, in Java, you must explicitly import most classes from external packages that you want to use <xref ref="importing-classes" text="type-global"/>. If you forget to import a class, the compiler will give you an error message like this:
121121
</p>
122+
<listing xml:id="importing-classes">
122123
<program language="java" interactive="activecode" line-numbers="yes">
123124

124125
<code>
@@ -133,6 +134,7 @@
133134
} // End of class
134135
</code>
135136
</program>
137+
</listing>
136138
<p>
137139
You may notice that this error message looks similar to the previous one, however, it has an entirely different cause. In Java, classes like <c>Scanner</c> that are part of external packages (like <c>java.util</c>) must be explicitly imported into your source file. Java does not automatically recognize these classes. To resolve this error, you need to add an import statement for the <c>Scanner</c> class at the beginning of your <c>Histo.java</c> file, typically import <c>java.util.Scanner;</c>.
138140
</p>

0 commit comments

Comments
 (0)