Java String Capitalize capitalize(String text)

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

Description

capitalize

License

Open Source License

Declaration

public static String capitalize(String text) 

Method Source Code

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

public class Main {
    public static String capitalize(String text) {

        if (text == null)
            return null;

        if (text.length() == 1)
            return text.toUpperCase();

        String s = "";

        for (int i = 0; i < text.length(); i++)
            if (i - 1 < 0 || text.charAt(i - 1) == ' ')
                s += ("" + text.charAt(i)).toUpperCase();
            else/*from   w w  w .  jav a2s . c  om*/
                s += ("" + text.charAt(i)).toLowerCase();

        return s;
    }
}

Related

  1. capitalize(String text)
  2. capitalize(String text)
  3. capitalize(String text)
  4. capitalize(String text)
  5. capitalize(String text)
  6. capitalize(String texte)
  7. capitalize(String to_capitalize)
  8. capitalize(String token)
  9. Capitalize(String val)