Android examples for java.lang:String Case
capitalize string via Character.toUpperCase()
import android.text.TextUtils; import java.util.ArrayList; import java.util.List; public class Main{ public static String capitalize(String str) { StringBuilder sb = new StringBuilder(str); for (int i = 0; i < sb.length(); i++) { if (i == 0 || Character.isWhitespace(sb.charAt(i - 1))) { sb.replace(i, i + 1, Character.toString(Character .toUpperCase(sb.charAt(i)))); }/*from www . j a va 2 s. c o m*/ } return sb.toString(); } }