Here you can find the source of capitalize(String input)
Parameter | Description |
---|---|
input | the input string (possibly empty) |
public static String capitalize(String input)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); public class Main { /**//from www.j a v a2s. c o m * Converts a string such that the first character is upper case. * * @param input the input string (possibly empty) * @return the string with the first character converted from lowercase to upper case (may * return the string unchanged if already capitalized) */ public static String capitalize(String input) { if (input.length() == 0) return input; char ch = input.charAt(0); if (Character.isUpperCase(ch)) return input; return String.valueOf(Character.toUpperCase(ch)) + input.substring(1); } }