Here you can find the source of capitalise(String s)
public static String capitalise(String s)
//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; } }