Android examples for java.lang:String Case
Capitalize the first char
import android.annotation.SuppressLint; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import java.net.URI; import java.net.URL; import java.util.AbstractCollection; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.Locale; public class Main{ /**/*from w w w . j a va 2s .c o m*/ * Capitalize the first char. * * @param s the string to be capitalized * @return Capitalized first char of the given word. */ @SuppressLint("DefaultLocale") public static String capitalize(String s) { if (s == null) return null; if (s.length() == 0) return s; return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase(); } }