2020.02.19 String常用类练习题2.0

时间:2022-01-22 22:29:40

package com.guoyun.StirngTest;

/**
* ClassName:
* Function: ADD FUNCTION
* Reason: ADD REASON
*
* @author
* @Date
* @since Ver 1.1
*/
public class Test12 {
public static void main(String[] args) {
int count1=0,count2=0,count3=0;
String str="ddejidsEFALDFfnef2357 3ed";
char[] chars=str.toCharArray();
for (int i = 0; i < chars.length; i ) {
if(chars[i]>=65&&chars[i]<=90){
count1 ;
}else if(chars[i]>=97&&chars[i]<=122){
count2 ;
}else {
count3 ;
}
}
System.out.println("该字符串中一共有" count1 "个大写字母和" count2 "个小写字母和" count3 "个非字母!");
}
}