aspose file tools*
The moose likes Beginning Java and the fly likes Scanner Strings and Ints dont play nice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Scanner Strings and Ints dont play nice" Watch "Scanner Strings and Ints dont play nice" New topic
Author

Scanner Strings and Ints dont play nice

Bryce Heath
Greenhorn

Joined: Sep 16, 2011
Posts: 19
Hey guys
I wanted to check this before I start researching into something thats not my problem
in the code

It seems if I use a string with anything else IE double int the string in the variable name does not print. If I both scans as ints or 1 int 1 double ect it prints fine. If I understood an earlier post it is a problem with the scan.nextLine I am using. I did look at some links provided for me but could not make heads or tails of it, and would like to know what specifically the code is doing when it does the scan.nextLine or even better if any 1 has a link to a good Scanner tutorial so I may understand a little better. Sorry Campbell if it seems im not putting in an effort on this problem but I have been googleing for hrs now and am a little frustrated, I hope this is not viewed badly.
Thank you again everyone for your continued patience with me, I know it can be annoying when people dont understand something.
Bryce Heath
Greenhorn

Joined: Sep 16, 2011
Posts: 19
Omg Now I feel really dumb, moments after posting this I figured it out. The .nextLine was not printing the string because the string was never skipped (not sure how a string could be skipped?) but by using just next it works fine. Sorry for the trouble, glad I got it figured out.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39409
    
  28
Back to your previous thread, where I warned you about nextLine(). Have a look at the previous link in that post, and see whether that helps you about nextLine().
 
Don't get me started about those stupid light bulbs.
 
subject: Scanner Strings and Ints dont play nice