"The first season of JAV entry" in the character category small case

Source: Internet
Author: User

/*
* 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.