Java String Capitalize capitalize(String str)

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

Description

capitalize

License

Open Source License

Declaration

public static String capitalize(String str) 

Method Source Code

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

public class Main {
    public static String capitalize(String str) {
        String[] parts = str.toLowerCase().split(" ");
        StringBuilder buf = new StringBuilder();
        for (String part : parts) {
            buf.append(part.substring(0, 1).toUpperCase() + part.substring(1) + " ");
        }/* w ww  .ja  v a  2s.  co m*/
        if (buf.length() > 1) {
            return buf.toString().trim();
        } else {
            return "";
        }
    }
}

Related

  1. capitalize(String str)
  2. capitalize(String str)
  3. capitalize(String str)
  4. capitalize(String str)
  5. capitalize(String str)
  6. capitalize(String str)
  7. capitalize(String str)
  8. capitalize(String str)
  9. capitalize(String str)