ordinary expression
<pre><code>Scanner kb = new Scanner(System.in);

System.out.print("&gt;&gt; ");
String line = kb.nextLine();

line = line.trim();
int i = 0;

do {
  int j = i;
  while ((!line.substring(j, j + 1).equals(" ")) &amp;&amp; (j &lt; line.length())) {
  //while ((j &lt; line.length())&amp;&amp;(!line.substring(j, j + 1).equals(" "))) {
    j++;
  }
  System.out.println("-&gt; " + line.substring(i, j));
  i = j;
  while ((line.substring(i, i + 1).equals(" "))&amp;&amp;(i&lt;line.length())) {
  //while ((i &lt; line.length()) &amp;&amp; (line.substring(i, i + 1).equals(" "))) {

    i++;
  }
}while (i &lt; line.length());
</code></pre>

<p>why expression ....</p>

<pre><code>while ((!line.substring(j, j + 1).equals(" ")) &amp;&amp; (j &lt; line.length())) 
</code></pre>

<p>not equal with</p>

<pre><code>while ((j &lt; line.length())&amp;&amp;(!line.substring(j, j + 1).equals(" ")))
</code></pre>
