Counting the number of characters in a variety of string

public class ClassfiedChar{
    
    public static void main(String[] args){
        
        String str = "ahGJ;j:NLKn;[][]mpon;l()mp'mUIGGUILB";
        char[] array = str.toCharArray();
        int up = 0;
        int low = 0;
        int other = 0;
        
        for(int i=0;i<str.length();i++){
            if('A' <= array[i] && array[i] <= 'Z'){
                up++;
            } else if( 'A' <= Array [I] && Array [I] <= 'Z' ) { 
                Low ++ ; 
            } the else { 
                OTHER ++ ; 
            } 
        } 
        
        System.out.println ( "capital letters" + up + "th "+" lowercase "Low + +" a "+" other characters "oTHER + +" a " ); 
    } 

}

 

Guess you like

Origin www.cnblogs.com/yxfyg/p/12365642.html