Update: I updated this tutorial in late 2012 after the note from Pablo Souza in the Comments section showing that the StringTokenizer class is now a "legacy class."
To split a string in Java into substrings, use the
splitmethod of the String class. For instance, given the following string:
String speech = "Four score and seven years ago";
You can split the string into substrings using the following line of code: