title: Java toTitleCase function
body: <p>I have this Java function that's supposed to convert the string <code>s</code> to title case.  It should return a <em>copy</em> of <code>s</code> to the caller, leaving <code>s</code> preserved.</p>
  
  <p>Currently, <code>rv</code> ends up as an empty string.  Can anyone tell me why?</p>
  
  <pre><code>private static String titleCase(String s) {
          String rv = new String();
          StringTokenizer strtok = new StringTokenizer(s);
          // handle the potential null error: (should really output a runtime warning here)
          if(s == null) return null;
          while(strtok.hasMoreTokens()) {
              String word = strtok.nextToken();
              String firstLetter = word.substring(0,1);
              String restOfWord = word.substring(1);
              rv.concat(firstLetter.toUpperCase() + restOfWord.toLowerCase());
          }
          return rv;
      }
  </code></pre>