Returns the number of characters in a Word
<pre><code>private static StringBuffer sb;

public static void main(String[] args) {
    // Text in a string
    String text = "This is a poor sentence in grammar.";

    String[] words = text.split("[ .!?]");
    for (int i = 0; i &lt; words.length; i++) {
        int counter = 0;
        if (words[i].length() &gt;= 1) {
            for (int k = 0; k &lt; words[i].length(); k++) {
                if (Character.isLetter(words[i].charAt(k)))
                    counter++;
            }
            sb = new StringBuffer();
            sb.append(counter).append(" ");
        }
    }
    System.out.println(sb);
}
</code></pre>

<p>Can we optimize this code more?
 My Ouptut is:-</p>

<pre><code>4 2 1 4 8 2 7 
</code></pre>
