1个回答
展开全部
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.next();
System.out.println(str);
int alphaNum=0,digitNum=0,otherNum=0;
for(char c:str.toCharArray()){
if(Character.isDigit(c))
digitNum++;
else if(Character.isAlphabetic(c)){
alphaNum++;
}else{
otherNum++;
}
}
System.out.println("alphaNum="+alphaNum+",digitNum="+digitNum+",otherNum="+otherNum);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询