This program counts the number of upper and lower case characters in a given string. Here's how it works:
This program can be useful in various applications where you need to analyze the character distribution in a given string.
class Count_Case { static void charCase_Count(StringBuffer str) { int lwr=0,upr=0,len = str.length(); for (int i = 0; i < len; i++) { Character c = str.charAt(i); if (Character.isLowerCase(c)) lwr+=1; else if (Character.isUpperCase(c)) upr+=1; // else // oth+=1; } System.out.println("Number of UpperCase : "+upr); System.out.println("Number of LowerCase : "+lwr); } public static void main(String[] args) { StringBuffer str = new StringBuffer("Tutor Joes"); charCase_Count(str); } }
Number of UpperCase : 2 Number of LowerCase : 7
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions