Java String Capitalize capitalize(String orig)

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

Description

capitalize

License

Open Source License

Declaration

static public String capitalize(String orig) 

Method Source Code

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

public class Main {
    static public String capitalize(String orig) {
        StringBuffer buf = new StringBuffer(orig);
        for (int i = 0; i < orig.length(); i++) {
            if (i == 0 || orig.charAt(i - 1) == ' ') {
                if (Character.isLowerCase(orig.charAt(i))) {
                    buf.setCharAt(i, Character.toUpperCase(orig.charAt(i)));
                }//from   w w  w.  j a  va2s .co  m
            }
        }

        String r = new String(buf);
        return r;
    }
}

Related

  1. capitalize(String name)
  2. capitalize(String name)
  3. capitalize(String name)
  4. capitalize(String name)
  5. capitalize(String name)
  6. capitalize(String original)
  7. capitalize(String propertyName)
  8. capitalize(String pString)
  9. capitalize(String s)