Java String Capitalize capitalize(String string)

Here you can find the source of capitalize(String string)

Description

capitalize

License

Open Source License

Declaration

private static String capitalize(String string) 

Method Source Code

//package com.java2s;
/**/*from   ww w .  j a  va2  s . co m*/
 * <copyright>
 * Copyright (c) 2010-2014 Henshin developers. 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
 * </copyright>
 */

public class Main {
    private static String capitalize(String string) {
        if (string == null || string.length() == 0)
            return string;
        String first = string.substring(0, 1).toUpperCase();
        if (string.length() == 1)
            return first;
        return first + string.substring(1);
    }
}

Related

  1. capitalize(String string)
  2. capitalize(String string)
  3. capitalize(String string)
  4. capitalize(String string)
  5. capitalize(String string)
  6. capitalize(String string)
  7. capitalize(String string)
  8. capitalize(String string)
  9. capitalize(String string)