Java: Print parts of a string
<p>I need to print out the first two words of whatever string is referenced into my construct and then print al subsequent words after, which is the part I an having trouble with.</p>

<pre><code>//Printing first two words of string
int space1 = songLine.indexOf(' ');//grabs location of first space, marking the end of first word
 String word1 = songLine.substring(0,space1);//first word of line

String word2Extract = songLine.substring(space1+1);//starting from first space + 1(end of first word)
 int space2 = word2Extract.indexOf(' ');
 String word2 = word2Extract.substring(0,space2);

 System.out.println("7: "+word1+" "+word2);
</code></pre>

<p>I'm not confident I am using the correct way of searching and finding the first two words...</p>

<p>Any help would be great ^^</p>
