Here you can find the source of capitalize(String input)
public static String capitalize(String input)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); public class Main { /**//from w w w .j ava 2 s . co m * Capitalizes the first character of a string. */ public static String capitalize(String input) { if (input.isEmpty()) { return input; } char first = input.charAt(0); char capitalized = Character.toUpperCase(first); return first == capitalized ? input : capitalized + input.substring(1); } }