Java - Write code to convert string to Lower Case using Character.toLowerCase()

Requirements

Write code to convert string to Lower Case

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String str = "book2s.com";
        System.out.println(toLowerCase(str));
    }/*from w  w w  . j a  va 2s.  c  o m*/

    public static String toLowerCase(String str) {
        StringBuffer buffer = new StringBuffer(str);
        for (int i = 0; i < buffer.length(); i++) {
            char c = buffer.charAt(i);
            buffer.setCharAt(i, Character.toLowerCase(c));
        }
        return buffer.toString();
    }
}

Related Exercise