Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

next vs hasnext() in Scanner

 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused between hasnext and next methods in the java.util.Scanner class. Please help.
 
Ankush Bhargava
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Cheers
Ankush
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic