Java String Capitalize capitalize(final String str)

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

Description

capitalize

License

Apache License

Declaration

private static String capitalize(final String str) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    private static String capitalize(final String str) {
        final char firstChar = str.charAt(0);
        final char newChar = Character.toUpperCase(firstChar);
        if (firstChar == newChar) {
            // already capitalized
            return str;
        }//from   w  w  w.j  a va2s  . c o  m

        char[] newChars = new char[str.length()];
        newChars[0] = newChar;
        str.getChars(1, str.length(), newChars, 1);
        return String.valueOf(newChars);
    }
}

Related

  1. capitalize(final String s)
  2. capitalize(final String s)
  3. capitalize(final String s)
  4. capitalize(final String s)
  5. capitalize(final String str)
  6. capitalize(final String str)
  7. capitalize(final String str)
  8. capitalize(final String str)
  9. capitalize(final String str)