/*
* The Character class wraps the value of a base type char in an object
* In addition, the class provides several methods to determine the category of characters in lowercase letters, numbers, and so on, and converts characters from uppercase to lowercase, and vice versa
*
*/
Here is a small case to look at the function of the character class:
Counts the number of occurrences of an uppercase character, a lowercase alphabetic character, and a numeric character in a string.
Previously wrote the code to complete this function, where it was not implemented according to the character class. It is recommended to read the blog first, because there is a bit of process-oriented meaning. Understanding that side, helps to realize the function of character. See blog http://write.blog.csdn.net/postlist/0/all/draft?t=del&id=51330695
The code is as follows:
public class Charactertest {public static void main (string[] args) {//defines three statistical variables. int bigcount = 0;int Smallcount = 0;int Numbercount = 0;//keyboard input a string. Scanner sc = new Scanner (system.in); System.out.println ("Please enter a string:"); String line = Sc.nextline ();//Converts a string to a character array. char[] CHS = Line.tochararray ();//traversal of the character array gets to each character for (int x = 0; x < chs.length; + +) {Char ch = chs[x];if (character.is Uppercase (CH)) {//uppercase bigcount++;} else if (Character.islowercase (CH)) {//lowercase smallcount++;} else if (Character.isdigit (ch ) {//digital numbercount++;}} The output can be System.out.println ("uppercase:" + Bigcount + "a"); SYSTEM.OUT.PRINTLN ("Lowercase letters:" + Smallcount + "a"); System.out.println ("Numeric character:" + Numbercount + "one");}}
The next entry enters the regular expression. http://blog.csdn.net/qq_32059827/article/details/51371479
"The first season of JAV entry" in the character category small case