Java String Capitalize capitalize(String words)

Here you can find the source of capitalize(String words)

Description

capitalize

License

Open Source License

Declaration

public static String capitalize(String words) 

Method Source Code

//package com.java2s;

public class Main {
    public static String capitalize(String words) {
        StringBuffer buffer = new StringBuffer();
        boolean isNewWord = true;
        int length = words.length();
        for (int i = 0; i < length; ++i) {
            char c = words.charAt(i);
            if (Character.isWhitespace(c)) {
                isNewWord = true;//from www . j  a  v a2s .c  o m
            } else if (isNewWord) {
                c = Character.toUpperCase(c);
                isNewWord = false;
            }
            buffer.append(c);
        }
        return buffer.toString();
    }
}

Related

  1. capitalize(String word)
  2. capitalize(String word)
  3. capitalize(String word)
  4. capitalize(String word)
  5. capitalize(String word)
  6. capitalize(StringBuilder text)
  7. capitalizeAt(StringBuilder builder, int index)
  8. capitalizeClass(String className)
  9. capitalized(String s)