title: Word counting using streams
body: <p>I tried to count words with Streams in Java. Here's what I tried:</p>
  
  <pre><code>public static int countWords(String s) {
      return s.chars().reduce((x, y) -&gt; {
          if((char)y == ' ')
              ++x;
          return x;
      }).orElse(0);
  }
  </code></pre>
  
  <p>But <code>countWords("asd")</code> return 97. Why? I thought that <code>chars</code> returns <code>IntStream</code> which actually consists of <code>char</code>s. So, I just cast it to <code>char</code>. What's wrong?</p>