Android String Case Convert capitalize(String plainMessage, char letter)

Here you can find the source of capitalize(String plainMessage, char letter)

Description

Replace all occurrences of letter in plainMessage with toUpperCase(letter)

Parameter

Parameter Description
plainMessage a parameter
letter a parameter

Return

plainMessage with all occurrences of letter in upper-case.

Declaration

public static String capitalize(String plainMessage, char letter) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from  ww  w. ja  v a 2  s . c o  m
     * Replace all occurrences of letter in plainMessage with toUpperCase(letter)
     * @param plainMessage
     * @param letter
     * @return plainMessage with all occurrences of letter in upper-case.
     */
    public static String capitalize(String plainMessage, char letter) {

        StringBuffer message = new StringBuffer(plainMessage);

        for (int i = 0; i < plainMessage.length(); i++) {
            char c = plainMessage.charAt(i);
            if (Character.isLetter(c)) {
                if (Character.toUpperCase(c) == Character
                        .toUpperCase(letter)) {
                    message.setCharAt(i, Character.toUpperCase(c));
                }
            }
        }

        return message.toString();
    }
}

Related

  1. endsWithIgnoreCase(final String target1, final String target2)
  2. startsWithIgnoreCase(final String target1, final String target2)
  3. toTitleCase(String s)
  4. camelString(String str, boolean firstCharacterUppercase)
  5. firstByteToLower(String instring)
  6. uncapitalize(String capitalizedMessage, char letter)
  7. toUpper(char ch)
  8. toLowerSubset(String source, char substitute)
  9. UpperCase(String str)