Here you can find the source of capitalize(String string)
Parameter | Description |
---|---|
string | the String to be processed |
public static String capitalize(String string)
//package com.java2s; public class Main { /**//www. j av a 2s.c om * Returns the specified string with its first character converted to * upper case. * * @param string the String to be processed * @return the specified string with its first character converted to * upper case */ public static String capitalize(String string) { int length = string.length(); if (length == 0) { return string; } else if (length == 1) { return string.toUpperCase(); } else { return (Character.toUpperCase(string.charAt(0)) + string.substring(1)); } } }