Here you can find the source of capitalizeFirst(String s)
Parameter | Description |
---|---|
s | the input string |
public static String capitalizeFirst(String s)
//package com.java2s; /**/*from ww w .j a va 2 s . c om*/ * Copyright (c) 2011 Martin Geisse * * This file is distributed under the terms of the MIT license. */ public class Main { /** * Returns the specified string, with the first character capitalized. * Returns null/empty if the argument is null/empty. * @param s the input string * @return the output string */ public static String capitalizeFirst(String s) { if (s == null) { return null; } else if (s.isEmpty()) { return s; } else { return Character.toUpperCase(s.charAt(0)) + s.substring(1); } } }