Here you can find the source of capitalize(String to_capitalize)
Parameter | Description |
---|---|
to_capitalize | is the <tt>String</tt> to be capitalized. |
public static String capitalize(String to_capitalize)
//package com.java2s; //License from project: Open Source License public class Main { /** This method capitalizes the first letter of the given <tt>String</tt>. * /*from w w w . j a v a 2 s. c o m*/ * @param to_capitalize * is the <tt>String</tt> to be capitalized. * @return the given <tt>String</tt> with the first character capitalized (if it is a letter). */ public static String capitalize(String to_capitalize) { if (to_capitalize == null || to_capitalize.equals("")) return to_capitalize; else if (to_capitalize.length() == 1) return to_capitalize.toUpperCase(); else return to_capitalize.substring(0, 1).toUpperCase() + to_capitalize.substring(1); } public static String substring(String string, String beginning, String end) { if (!string.contains(beginning) || !string.contains(end) || string.indexOf(beginning) >= string.indexOf(end)) return null; else { String after_beginning = string.substring(string.indexOf(beginning) + beginning.length()); return after_beginning.substring(0, after_beginning.indexOf(end)); } } }