StringBuffer Append Space (" ") Appends "null" Instead
<p>Basically what I'm trying to do is take a String, and replace each letter in the alphabet inside, but preserving any spaces and not converting them to a "null" string, which is the main reason I am opening this question.</p>

<p>If I use the function below and pass the string "a b", instead of getting "ALPHA BETA" I get "ALPHAnullBETA".</p>

<p>I've tried all possible ways of checking if the individual char that is currently iterated through is a space, but nothing seems to work. All these scenarios give false as if it's a regular character.</p>

<pre><code>public String charConvert(String s) {

    Map&lt;String, String&gt; t = new HashMap&lt;String, String&gt;(); // Associative array
    t.put("a", "ALPHA");
    t.put("b", "BETA");
    t.put("c", "GAMA");
    // So on...

    StringBuffer sb = new StringBuffer(0);
    s = s.toLowerCase(); // This is my full string

    for (int i = 0; i &lt; s.length(); i++) {
        char c = s.charAt(i);

        String st = String.valueOf(c);
        if (st.compareTo(" ") == 1) {
            // This is the problematic condition
            // The script should just append a space in this case, but nothing seems to invoke this scenario
        } else {
            sb.append(st);
        }

    }

    s = sb.toString();

    return s;
}
</code></pre>
