final static int NOT_FOUND = -1;
String s = "Matching patterns in Strings";
int j1 = s.indexOf (" "); // Find first space
if (NOT_FOUND != j1) // If a space was found
{
int j2 = s.indexOf (" ", j1 + 1); // Find next space
// ...
}
int jn = s.lastIndexOf (" "); // Find last space
Java does also have regular expressions - later.