Java String Capitalize capitalise(String s)

Here you can find the source of capitalise(String s)

Description

capitalise

License

Open Source License

Declaration

public static String capitalise(String s) 

Method Source Code

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

public class Main {
    public static String capitalise(String s) {
        String finalString = "";
        if (s.contains(" ")) {
            StringBuilder builder = new StringBuilder();
            String[] sp = s.split(" ");
            for (String string : sp) {
                string = string.substring(0, 1).toUpperCase() + string.substring(1).toLowerCase();
                builder.append(string);/*from   w  w w  . j  av  a 2 s  . co m*/
                builder.append(" ");
            }
            builder.deleteCharAt(builder.length() - 1);
            finalString = builder.toString();
        } else {
            finalString = s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
        }
        return finalString;
    }
}

Related

  1. capitalise(String line)
  2. capitalise(String name)
  3. capitalise(String s)
  4. capitalise(String s)
  5. capitalise(String s)
  6. capitalise(String str)
  7. capitalise(String str)
  8. capitalise(String str)
  9. capitalise(String string)