Java String Capitalize capitalize(final String word)

Here you can find the source of capitalize(final String word)

Description

capitalize

License

Open Source License

Declaration

public static String capitalize(final String word) 

Method Source Code

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

public class Main {
    public static String capitalize(final String word) {
        char chars[] = word.toCharArray();

        if (chars.length >= 1) {
            chars[0] = Character.toUpperCase(chars[0]);
        }/*from  ww w.  j av a 2 s .c  o m*/

        if (chars.length >= 2) {
            for (int i = 1; i < chars.length; i++) {
                if (chars[i - 1] == ' ' || chars[i - 1] == '\'' || chars[i - 1] == '-') {
                    chars[i] = Character.toUpperCase(chars[i]);
                }
            }
        }

        return String.valueOf(chars);
    }
}

Related

  1. capitalize(final String text)
  2. capitalize(final String value)
  3. capitalize(final String value)
  4. capitalize(final String value)
  5. capitalize(final String value)
  6. capitalize(String capitalizeMe)
  7. capitalize(String constraint)
  8. capitalize(String content)
  9. capitalize(String data)