Java Utililty Methods String Capitalize

List of utility methods to do String Capitalize

Description

The list of methods to do String Capitalize are organized into topic(s).

Method

Stringcapitalise(final String name)
capitalise
String s = name;
switch (s.length()) {
case 0: {
    break;
case 1: {
    s = name.toUpperCase();
    break;
...
Stringcapitalise(String line)
Returns the given string with the first letter capitalised
return Character.toUpperCase(line.charAt(0)) + line.substring(1);
Stringcapitalise(String name)
capitalise
return Character.toUpperCase(name.charAt(0)) + name.substring(1);
Stringcapitalise(String s)
Converts a string to all lower case, and capitalises the first letter of the string
if ((s == null) || (s.length() == 0))
    return s;
char[] chars = s.toLowerCase().toCharArray();
chars[0] = Character.toUpperCase(chars[0]);
return String.valueOf(chars);
Stringcapitalise(String s)
Change the first letter of a string to upper case.
return s.isEmpty() ? s : s.charAt(0) + s.substring(1);
Stringcapitalise(String s)
capitalise
String finalString = "";
if (s.contains(" ")) {
    StringBuilder builder = new StringBuilder();
    String[] sp = s.split(" ");
    for (String string : sp) {
        string = string.substring(0, 1).toUpperCase() + string.substring(1).toLowerCase();
        builder.append(string);
        builder.append(" ");
...
Stringcapitalise(String s)
Describe what the method does
if (s.equals("")) {
    return "";
if (s.length() == 1) {
    return s.toUpperCase();
} else {
    String caps = s.substring(0, 1).toUpperCase();
    String rest = s.substring(1);
...
Stringcapitalise(String str)
Returns a capitalised version of the given String
if (str == null) {
    return null;
if (str.length() <= 1) {
    return str.toUpperCase();
return str.substring(0, 1).toUpperCase() + str.substring(1, str.length());
Stringcapitalise(String str)

Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .

return capitalize(str);
Stringcapitalise(String str)

Capitalise a String.

That is, convert the first character into title-case.

if (str == null) {
    return null;
} else if (str.length() == 0) {
    return "";
} else {
    return new StringBuilder(str.length()).append(Character.toTitleCase(str.charAt(0)))
            .append(str, 1, str.length()).toString();