File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes hasNext() and hasNextXXX() Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "hasNext() and hasNextXXX() Problem" Watch "hasNext() and hasNextXXX() Problem" New topic

hasNext() and hasNextXXX() Problem

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

K&B book
self test
question 15

i have modified it.

1.It complies fine but when it runs ,it just hangs up after displaying

1 2 a 3 45 6 1 2

how to remove this problem

2.if i want
1 2 a 3 45 6 1 2 3 45 6
in the output,then what change should i do in the program ?

OCPJP 6.0 93%
OCPJWCD 5.0 98%
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Hi, try this....

|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Michael Angstadt
Ranch Hand

Joined: Jun 17, 2009
Posts: 276

The problem is in the second loop. If a token is not an integer, it never advances to the next token and gets caught in an infinite loop.

I agree. Here's the link:
subject: hasNext() and hasNextXXX() Problem
jQuery in Action, 3rd edition