Java - Write code to change First Character To Lower Case

Requirements

Write code to change First Character To Lower Case

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String upperCaseStr = "Book2s.com";
        System.out.println(changeFirstCharacterToLowerCase(upperCaseStr));
    }/*from   w  ww. j  a v a 2  s .  c o m*/

    public static final String changeFirstCharacterToLowerCase(
            String upperCaseStr) {
        char[] chars = new char[1];
        chars[0] = upperCaseStr.charAt(0);
        String temp = new String(chars);
        if (chars[0] >= 'A' && chars[0] <= 'Z') {
            upperCaseStr = upperCaseStr.replaceFirst(temp,
                    temp.toLowerCase());
        }
        return upperCaseStr;
    }
}

Related Exercise