Java Help

Soldato
Joined
27 Aug 2004
Posts
17,111
Location
Geordieland
Im stumped on part of my java homework at uni and could do with a hint on what i need to do to be honest.

Anyways, i need to figure out how to seperatea a single input string, more specifically a name into 2 words. The name is stored as a string in a driver class and needs to be seperated into the first and last name and then printed as 2 seperate strings, but ill be damned if i can think how get java to find the space in the string.

Only thing i can actually think of doing is to put it into a while/for loop ad go 1 by 1 along the charAt until it finds a char position with no value contained in it, with anything behind the space being word 1 and after the space word 2, but im probably way off the mark.

Also, does anyone have any good java tutorial websites? My lectorals are useless and never really covers things properly. Was fine in semester 1, but sem 2 is getting very difficult.

Cheers for any help
 
Last edited:
MaxPower said:
Good luck and I hope your not attempting this at this time of night :D .

no no, not this late. Trying to read up on it to try to figure out hints as to how to do it, gonna do it tomorrow.

I will point you in the right direction but you will learn more if you experiment yourself.

Thats all i was after, a bit of hinting as to how to start :)

CHeers for the help guys, much appreciated! :D
 
Got the majority of it working now using the tokenizer, handy function that is. Gonna have a look at the other suggested ways too, the more i know the better :)

Thanks for the help to everyone, wouldnt have known where to start otherwise :)
 
Last edited:
Back
Top Bottom