Here you can find the source of capitalize(String s)
Parameter | Description |
---|---|
s | the input string |
public static String capitalize(String s)
//package com.java2s; public class Main { /**/*from www . j av a 2s. c om*/ * Capitalize a word * * @param s * the input string * @return capitalized string */ public static String capitalize(String s) { int len = s.length(); if (len == 0) return s; return new StringBuilder(len).append(Character.toTitleCase(s.charAt(0))).append(s.substring(1)).toString(); } public static String toString(String[] content, String sign) { if (null == content) { return null; } sign = null == sign ? "," : sign; StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < content.length; i++) { strBuilder.append(content[i]); if (i < content.length - 1) { strBuilder.append(sign); } } return strBuilder.toString(); } }