Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

use delimiter

843785Nov 2 2008 — edited Nov 2 2008
Having some trouble using a delimiter in the scanner class. I've been reading trying to find out why and i cant find an explanation or a better way but i figure people must run into this problem at least a few times.
 Scanner input = new Scanner (System.in);
 input.useDelimiter("-");
 rank=input.next();
 suit=input.next();
i want the input to be like 4-H but it wont accept it until i put 4-H- how can i make it accept it with whitespace at the end?

i tried doing
suit=input.nextLine();
but then it returns
4
-H
as the variables...
im also trying to make suit a char but theres no nextChar(); method for scanner apperantly. if there is please tell me.
Thanks in advance.
-Del

Edited by: del3226 on Nov 2, 2008 11:24 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 30 2008
Added on Nov 2 2008
8 comments
256 views