Gets the number of uppercase letters, lowercase letters, and numbers in the specified string.

The code is as follows:

import java. util. Scanner; /* * Gets the number of uppercase letters, lowercase letters, and numbers in the specified string*/ Public class stringtest {public static void main (string [] args) {system.out.println ("please enter string:"); scanner SC = new scanner (system. In); string input = sc.next(); system.out.print ("string is:"); system.out.println (input); getcount (input);} public static void getCount(String input){ char[] array=input.tocharArray(); int a=0,b=0,c=0; for(int i=0;i
='a'&&array[i]<='z') a++; else if(array[i]>='A'&&array[i]<='Z') b++; else if(array[i]>='0'&&array[i]<='9') c++; } System. out. Println ("uppercase letters" + B + "and lowercase letters" + A + "and numbers" + C + ");}}

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>