Write code to to Upper Case First One
//package com.book2s; public class Main { public static void main(String[] argv) { String str = "book2s.com"; System.out.println(toUpperCaseFirstOne(str)); }//ww w . j a va2 s. co m public static String toUpperCaseFirstOne(String str) { if (Character.isUpperCase(str.charAt(0))) { return str; } else { return (new StringBuilder()) .append(Character.toUpperCase(str.charAt(0))) .append(str.substring(1)).toString(); } } public static String toString(Object obj) { return obj == null ? "" : obj.toString(); } public static String toString(Object obj, String nullStr) { return obj == null ? nullStr : obj.toString(); } }