Here you can find the source of capitalize(String input)
Parameter | Description |
---|---|
input | to capitalize first character |
public static String capitalize(String input)
//package com.java2s; //License from project: Apache License public class Main { /**//from ww w.ja va2s . c o m * Capitalizes first character in given string * * @param input to capitalize first character * @return capitalized string or null if null */ public static String capitalize(String input) { if (input == null) { return null; } if (input.length() > 1) { for (int i = 0; i < input.length(); i++) { if (Character.isAlphabetic(input.charAt(i))) { return input.substring(0, i) + Character.toString(input.charAt(i)) .toUpperCase() + input.substring(i + 1); } } } return input.toUpperCase(); } }