Java String Capitalize capitalizeString(String string)

Here you can find the source of capitalizeString(String string)

Description

capitalize String

License

Open Source License

Declaration

public static String capitalizeString(String string) 

Method Source Code

//package com.java2s;

public class Main {
    public static String capitalizeString(String string) {
        char[] chars = string.toLowerCase().toCharArray();
        boolean found = false;
        for (int i = 0; i < chars.length; i++) {
            if (!found && Character.isLetter(chars[i])) {
                chars[i] = Character.toUpperCase(chars[i]);
                found = true;/*from ww  w .ja va2 s .  c om*/
            } else if (Character.isWhitespace(chars[i]) || chars[i] == '.' || chars[i] == '\'') { // You can add other chars here
                found = false;
            }
        }
        return String.valueOf(chars);
    }
}

Related

  1. capitalizeString(final String in)
  2. capitalizeString(String aString)
  3. capitalizeString(String str)
  4. capitalizeString(String string)
  5. capitalizeString(String string)
  6. capitalizeString(String text, boolean replaceUnderscore)
  7. capitalizeString(String toCapitalize)
  8. capitalizeToUpper(String line)
  9. toCapitalized(Object obj)