Java program for making string to lowercase entirely if it is containing any uppercase letter in it.

 Java program for making string to lowercase entirely if it is containing any uppercase letter in it.



Description:-

This java program converts the string into a string which will have only lowercase letters in it if that string had uppercase at the time of given it as an input.


Code:-

public class Solution {
    public String solve(String A) {

        char[] chArray = A.toCharArray();

        for(int i=0;i<chArray.length;i++){
            if(chArray[i]>='A' && chArray[i]<='Z'){
                chArray[i]= (char) (chArray[i]+32);
            }
        }  
        return String.valueOf(chArray);
    }
}

 

Feedback:-

After reading this page if you have any feedback do let me know in comments; i will try to bring those things in my upcoming posts.

Comments

Popular Posts