Java String Capitalize capitalize(String string)

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

Description

capitalize

License

Open Source License

Declaration

public static String capitalize(String string) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String capitalize(String string) {
        char[] letters = string.toCharArray();

        for (int index = 0; index < letters.length; index++) {
            if (index != 0 && !Character.isWhitespace(letters[index - 1]))
                continue;

            if (!Character.isLowerCase(letters[index]))
                continue;

            letters[index] = Character.toUpperCase(letters[index]);
        }/*from  w ww .  j  av  a  2  s. c  om*/

        return new String(letters);
    }
}

Related

  1. capitalize(String string)
  2. capitalize(String string)
  3. capitalize(String string)
  4. capitalize(String string)
  5. capitalize(String string)
  6. capitalize(String string, boolean firstWordOnly)
  7. capitalize(String string, int index)
  8. capitalize(String string0)
  9. capitalize(String text)