mercredi 11 mars 2015

return the first word in any string (Java)



I have to be able to input any two words as a string, and then invoke and display the first word returned from the method, and the method has to be a for loop method I kind of know how to use substring, and I know how to return the first word by just using .substring(0,x) x being how long the first word is. But how can I make it so that no matter what phrase I use for the string, it will always return the first word? And please explain what you do, because this is my first year in a CS class. Thank you!




Aucun commentaire:

Enregistrer un commentaire