Here you can find the source of capitalize(String string, int index)
public static String capitalize(String string, int index)
//package com.java2s; //License from project: Open Source License public class Main { public static String capitalize(String string, int index) { if (index >= string.length() || index < 0) { throw new StringIndexOutOfBoundsException(index); }/*from w w w.jav a 2 s . c om*/ final StringBuilder stringBuilder = new StringBuilder(string.length()); if (index != 0) { stringBuilder.append(string, 0, index); } stringBuilder.append(Character.toUpperCase(string.charAt(index))); if (index != string.length() - 1) { stringBuilder.append(string.substring(index + 1)); } return stringBuilder.toString(); } }