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
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: