Skip to content

Commit c37c607

Browse files
authored
Merge pull request #355 from habibasorour/issue_350_listing
added listing tag
2 parents 69330dc + 05dde6e commit c37c607

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

source/ch9_commonmistakes.ptx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
</p>
2424

2525
<p>
26-
Consider the following example where we have a method that multiplies a number by two. We can add print statements to help us debug the code:
26+
Consider the following example where we have a method that multiplies a number by two. We can add print statements to help us debug the code and verify that the method is being called correctly and returning the expected result as shown below in <xref ref="println-debugging" text="type-global"/>.
2727
</p>
28+
<listing xml:id="println-debugging">
2829
<program language="java" interactive="activecode" line-numbers="yes">
2930
<code>
3031
// DebugExample.java
@@ -45,8 +46,9 @@
4546
}//End of class
4647
</code>
4748
</program>
49+
</listing>
4850
<p>
49-
In the example above, <c>System.out.println()</c> is used inside both <c>main</c> and <c>multiplyByTwo()</c> to trace what values are being passed and returned. This kind of print-based debugging can quickly reveal logic errors, unexpected behavior, or whether a method is even being called. However, overuse of this technique will often take more time than using the debugging tools that are built into your IDE.
51+
In <xref ref="println-debugging" text="type-global"/>, <c>System.out.println()</c> is used inside both <c>main</c> and <c>multiplyByTwo()</c> to trace what values are being passed and returned. This kind of print-based debugging can quickly reveal logic errors, unexpected behavior, or whether a method is even being called. However, overuse of this technique will often take more time than using the debugging tools that are built into your IDE.
5052
</p>
5153
<p>
5254
Useful tools in the built-in Java debugger can help you step through your code, inspect variables, and evaluate expressions at runtime. Familiarizing yourself with these tools can greatly enhance your debugging efficiency.

0 commit comments

Comments
 (0)