Java String Capitalize All capitalizeAll(String text)

Here you can find the source of capitalizeAll(String text)

Description

capitalize All

License

Open Source License

Declaration

public static String capitalizeAll(String text) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String capitalizeAll(String text) {
        if (text == null || text.length() == 0)
            return "null";
        text = text.toLowerCase();/* w  w  w.  j  a  va2s  .  c o  m*/
        String result = "";
        for (int i = 0; i < text.length(); i++) {
            if (i == 0 || i > 1 && text.charAt(i - 1) == ' ')
                result += Character.toString(text.charAt(i)).toUpperCase();
            else
                result += text.charAt(i);
        }
        return result;
    }
}

Related

  1. capitaliseAllWords(String str)
  2. capitaliseAllWords(String str)
  3. capitaliseAllWords(String str)
  4. capitalizeAll(final String value)
  5. capitalizeAll(String string)
  6. capitalizeAllFirstChar(String text)
  7. capitalizeAllWords(String text)
  8. capitalizeAllWords(String words)