Write code to convert first letter to Uppercase
//package com.book2s; public class Main { public static void main(String[] argv) { String str = "book2s.com"; System.out.println(firstUpper(str)); }//from w ww . j ava2 s. c om public static String firstUpper(String str) { return str.substring(0, 1).toUpperCase().concat(str.substring(1)); } /** * same as String.substring, except that this version handles the case * robustly when the index is out of bounds. */ public static String substring(String str, int beginIndex) { if (str == null) return null; if (beginIndex < 0) return str; if (beginIndex >= str.length()) return ""; return str.substring(beginIndex); } /** * same as String.substring, except that this version handles the case * robustly when one or both of the indexes is out of bounds. */ public static String substring(String str, int beginIndex, int endIndex) { if (str == null) return null; if (beginIndex > endIndex) return ""; if (beginIndex < 0) beginIndex = 0; if (endIndex > str.length()) endIndex = str.length(); return str.substring(beginIndex, endIndex); } }