Here you can find the source of capitalize(final String input)
Parameter | Description |
---|---|
input | the input; may be null or empty |
public static String capitalize(final String input)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007, 2013 compeople AG and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://w w w . ja v a 2s. c o m * compeople AG - initial API and implementation *******************************************************************************/ public class Main { /** * Return the input string with the first character converted to upper case. * * @param input * the input; may be null or empty * @return the input with the first character converted to upper case, or * null (if input is null), or "" if input is "" * */ public static String capitalize(final String input) { String result = input; if (input != null && input.length() > 0) { result = input.substring(0, 1).toUpperCase(); if (input.length() > 1) { result += input.substring(1); } } return result; } }