This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes next vs hasnext() in Scanner Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "next vs hasnext() in Scanner" Watch "next vs hasnext() in Scanner" New topic

next vs hasnext() in Scanner

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

I am confused between hasnext and next methods in the java.util.Scanner class. Please help.

Ankush Bhargava

Joined: Dec 03, 2004
Posts: 19
what is the confusion Pradeep?
is it the use of them that's confusing you? Well, hasNext is used to find out whether another token is available, whereas, next is used to get that 'next' token!

hope this helps.

I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: next vs hasnext() in Scanner
It's not a secret anymore!