• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sacnner Issues  RSS feed

 
Ishan Pandya
Ranch Hand
Posts: 228
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiee everyone..!!
I am using Scanner Class for separating the tokens.
Here is the code.



I want the Integer value from the String defined in the class. But i am not getting any output (i.e the output is blank and I am expecting 101 as output).
 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to be aware of the fact that a token is a single word ( without space delimiters ) .

 
Ishan Pandya
Ranch Hand
Posts: 228
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saif Asif wrote:You need to be aware of the fact that a token is a single word ( without space delimiters ) .


So you mean I have to use StringTokenizer instead of Scanner?
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. You should not use string tokenizer at all. If that is the input, you will need to change the delimiter on your Scanner.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!