Java String Capitalize capitalize(final String text)

Here you can find the source of capitalize(final String text)

Description

capitalize

License

Open Source License

Declaration

private static String capitalize(final String text) 

Method Source Code

//package com.java2s;
/*//from  w ww.j  ava 2s.  co  m
 *    Debrief - the Open Source Maritime Analysis Application
 *    http://debrief.info
 *
 *    (C) 2000-2014, PlanetMayo Ltd
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the Eclipse Public License v1.0
 *    (http://www.eclipse.org/legal/epl-v10.html)
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 */

public class Main {
    private static String capitalize(final String text) {
        if (text == null) {
            throw new NullPointerException();
        }
        if (text.length() == 0) {
            return text;
        }
        final char firstChar = text.charAt(0);
        return Character.isUpperCase(firstChar) ? text : Character.toUpperCase(firstChar) + text.substring(1);
    }
}

Related

  1. capitalize(final String str)
  2. capitalize(final String str)
  3. capitalize(final String str)
  4. capitalize(final String str)
  5. capitalize(final String str, final char... delimiters)
  6. capitalize(final String value)
  7. capitalize(final String value)
  8. capitalize(final String value)
  9. capitalize(final String value)