jQuery in Action, 3rd edition
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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

Scanner Strings and Ints dont play nice

Bryce Heath

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

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

Joined: Oct 13, 2005
Posts: 44588
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().
I agree. Here's the link: http://aspose.com/file-tools
subject: Scanner Strings and Ints dont play nice
It's not a secret anymore!