Java Reference
In-Depth Information
Looking further, you will find that end is set to 3, not 4, as you would expect. And
text contains the string ÑhellÑ , not ÑhelloÑ . Thus, it is no wonder that
countSyllables returns the answer 1. We'll need to look elsewhere for the
culprit. Apparently, the Word constructor contains an error.
Unfortunately, a debugger cannot go back in time. Thus, you must stop the debugger,
set a breakpoint in the Word constructor, and restart the debugger. Supply the input
once again. The debugger will stop at the beginning of the Word constructor. The
constructor sets two variables i and j , skipping past any nonletters at the beginning
and the end of the input string. Set a breakpoint past the end of the second loop (see
Figure 9 ) so that you can inspect the values of i and j .
Figure 8
The Current Values of the Local and Instance Variables
270
Search WWH ::




Custom Search