The code is correct and will convert all uppercase characters in the given string to lowercase. The code works by iterating over each character in the string and checking if it is an uppercase character using the Character.isUpperCase() method. If the character is uppercase, it is replaced with its lowercase equivalent using the Character.toLowerCase() method.
The convert_lowercase() method takes a StringBuffer object as input and modifies it in-place. The modified string with all lowercase characters is then printed using System.out.println().
class String_LowerCase { static void convert_lowercase(StringBuffer str) { int len = str.length(); for (int i = 0; i < len; i++) { Character c = str.charAt(i); if (Character.isUpperCase(c)) str.replace(i, i + 1,Character.toLowerCase(c) + ""); } } public static void main(String[] args) { StringBuffer str = new StringBuffer("Tutor Joes Computer Education"); System.out.println("Given String : "+str); convert_lowercase(str); System.out.println("Convert LowerCase : "+str); } }
Given String : Tutor Joes Computer Education Convert LowerCase : tutor joes computer education
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions