Here you can find the source of capitalizeFirstCharacter(final String s)
Parameter | Description |
---|---|
s | The string to capitalize. |
public static String capitalizeFirstCharacter(final String s)
//package com.java2s; /*/*from www . j a v a 2s.co m*/ * File: Strings.java * Authors: Justin Basilico * Company: Sandia National Laboratories * Project: Cognitive Foundry * * Copyright August 23, 2007, Sandia Corporation. Under the terms of Contract * DE-AC04-94AL85000, there is a non-exclusive license for use of this work by * or on behalf of the U.S. Government. Export of this program may require a * license from the United States Government. See CopyrightHistory.txt for * complete details. * * */ public class Main { /** * Capitalizes the first character of the given string. * * @param s The string to capitalize. * @return The given string with the first character capitalized. */ public static String capitalizeFirstCharacter(final String s) { if (s == null) { return null; } else if (s.length() <= 0) { return ""; } else { return s.substring(0, 1).toUpperCase() + s.substring(1); } } }