This has been annoying me for a few days now, probably a really simple solution but I can't figure out the best way to do it. I have a string consisting of two words and then a number (wordone wordtwo 20) and I need to set that number to an int. I have tried using the space as a delimiter and putting wordone and wordtwo in two separate strings but this is a really annoying way of doing it. Is there any simple way of reading any numbers in a string?
[cpp]
Scanner in = new Scanner(yourString);
String word1 = in.next();
String word2 = in.next();
int yourInt = in.nextInt();
[/cpp]
Thanks, just noticed the typo in the title. Has been a long day... :(
Sorry, you need to Log In to post a reply to this thread.