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

Stringcapitalize(final String str)
capitalize the first letter of a string
if (str == null) {
    return str;
int strLen = str.length();
if (strLen == 0) {
    return str;
return new StringBuilder(strLen).append(Character.toTitleCase(str.charAt(0))).append(str.substring(1))
...
Stringcapitalize(final String str, final char... delimiters)
capitalize
final int delimLen = delimiters == null ? -1 : delimiters.length;
if (isEmpty(str) || delimLen == 0) {
    return str;
final char[] buffer = str.toCharArray();
boolean capitalizeNext = true;
for (int i = 0; i < buffer.length; i++) {
    final char ch = buffer[i];
...
Stringcapitalize(final String text)
capitalize
if (text == null) {
    throw new NullPointerException();
if (text.length() == 0) {
    return text;
final char firstChar = text.charAt(0);
return Character.isUpperCase(firstChar) ? text : Character.toUpperCase(firstChar) + text.substring(1);
...
Stringcapitalize(final String value)
Transforms only the first letter in UpperCase (Capitalized)
if (value == null)
    return null;
if (value.trim().isEmpty())
    return value;
char[] arr = value.toCharArray();
LOOP: for (int i = 0; i < arr.length; i++) {
    char c = arr[i];
    switch (c) {
...
Stringcapitalize(final String value)
capitalize
final String[] parts = value.toLowerCase().split("\\s");
final StringBuilder cap = new StringBuilder();
if (parts.length > 1) {
    int count = 0;
    for (String part : parts) {
        cap.append(upperCaseFirst(part));
        if (count < parts.length) {
            cap.append(" ");
...
Stringcapitalize(final String value)
Returns the capitalize version of the given string.
if (value == null || value.isEmpty()) {
    return value;
char entry = value.charAt(0);
if (!Character.isLetter(entry) || Character.isUpperCase(entry)) {
    return value;
return Character.toUpperCase(entry) + value.substring(1);
...
Stringcapitalize(final String value)
capitalize
String result = "";
boolean capitalize = true;
for (final char c : value.toCharArray()) {
    final boolean isLetter = Character.isLetter(c);
    if (isLetter) {
        result += (capitalize || Character.isUpperCase(c)) ? Character.toUpperCase(c)
                : Character.toLowerCase(c);
    capitalize = !isLetter;
return result;
Stringcapitalize(final String word)
capitalize
char chars[] = word.toCharArray();
if (chars.length >= 1) {
    chars[0] = Character.toUpperCase(chars[0]);
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]);
...
Stringcapitalize(String capitalizeMe)
capitalize
if (capitalizeMe == null) {
    throw new NullPointerException("capitalizeMe is null");
} else if (capitalizeMe.length() == 0) {
    return capitalizeMe;
return capitalizeMe.substring(0, 1).toUpperCase() + capitalizeMe.substring(1);
Stringcapitalize(String constraint)
Capitalizes a string, which means the first character will be uppercase and the other characters will be lowercase.
if (constraint == null || constraint.length() == 0) {
    return constraint;
constraint = constraint.toLowerCase();
StringBuffer buffer = new StringBuffer();
buffer.append(Character.toUpperCase(constraint.charAt(0)));
buffer.append(constraint.substring(1));
return buffer.toString();
...