Java String Capitalize capitalize(String s)

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

Description

Capitalize a word

License

Open Source License

Parameter

Parameter Description
s the input string

Return

capitalized string

Declaration

public static String capitalize(String s) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from www  .  j  av  a  2s. c  om*/
     * Capitalize a word
     * 
     * @param s
     *            the input string
     * @return capitalized string
     */
    public static String capitalize(String s) {
        int len = s.length();
        if (len == 0)
            return s;
        return new StringBuilder(len).append(Character.toTitleCase(s.charAt(0))).append(s.substring(1)).toString();
    }

    public static String toString(String[] content, String sign) {
        if (null == content) {
            return null;
        }

        sign = null == sign ? "," : sign;
        StringBuilder strBuilder = new StringBuilder();
        for (int i = 0; i < content.length; i++) {
            strBuilder.append(content[i]);
            if (i < content.length - 1) {
                strBuilder.append(sign);
            }
        }

        return strBuilder.toString();
    }
}

Related

  1. capitalize(String original)
  2. capitalize(String propertyName)
  3. capitalize(String pString)
  4. capitalize(String s)
  5. capitalize(String s)
  6. capitalize(String s)
  7. capitalize(String s)
  8. capitalize(String s)
  9. capitalize(String s)