Java Fundamentals Hardening 69: Character Overview of basic type wrapper classes and character common methods

Source: Internet
Author: User

1. Character Overview:

1  Public Final class Character  extends  implements  serializable,comparable<character>

The character class wraps the value of a base type char in an object. An object of type character contains a single field of type Char.

In addition, the class provides several methods to determine the categories of characters (lowercase letters, numbers, and so on), and to convert characters from uppercase to lowercase, and vice versa.

2. How to construct character:

1 Character (char value);

Note : Constructs a newly assigned character object to represent the specified char value

1  Packagecn.itcast_01;2 3 /*4 * The Character class wraps the value of a base type char in an object5 * In addition, the class provides several methods to determine the categories of characters (lowercase letters, numbers, and so on) and convert characters from uppercase to lowercase, and vice versa6  * 7 * Construction Method:8 * Character (char value)9  */Ten  Public classCharacterdemo { One      Public Static voidMain (string[] args) { A         //Creating Objects -         //Character ch = new Character ((char)); -Character ch =NewCharacter (' a '); theSYSTEM.OUT.PRINTLN ("Ch:" +ch); -     } -}

3. Character class member Method:

1  Public Static  BooleanIsuppercase (Charch);//Determine if the character is uppercase or lowercase 2  Public Static  BooleanIslowercase (Charch);//determine if lowercase characters 3  Public Static  BooleanIsDigit (Charch);//Determine if it is a numeric character 4  Public Static  ChartoUpperCase (Charch);//Convert the given character to uppercase characters 5  Public Static  ChartoLowerCase (CharCH);//Converts the given character to lowercase characters

Method Use case:

1  Packagecn.itcast_02;2 3 /*4 * public static Boolean isuppercase (char ch): Determines whether the given character is uppercase characters5 * public static Boolean islowercase (char ch): Determines whether the given character is lowercase characters6 * public static Boolean isdigit (char ch): Determines whether a given character is a numeric character7 * public static char touppercase (char ch): Converts the given character to uppercase characters8 * public static char tolowercase (char ch): Converts the given character to lowercase characters9  */Ten  Public classCharacterdemo { One      Public Static voidMain (string[] args) { A         //Public Static Boolean isuppercase (char ch): Determines whether the given character is uppercase characters -System.out.println ("isuppercase:" + character.isuppercase (' A ')); -System.out.println ("isuppercase:" + character.isuppercase (' a ')); theSystem.out.println ("isuppercase:" + character.isuppercase (' 0 '))); -System.out.println ("-----------------------------------------"); -         //Public Static Boolean islowercase (char ch): Determines whether the given character is lowercase characters -System.out.println ("islowercase:" + character.islowercase (' A ')); +System.out.println ("islowercase:" + character.islowercase (' a ')); -System.out.println ("islowercase:" + character.islowercase (' 0 '))); +System.out.println ("-----------------------------------------"); A         //Public Static Boolean isdigit (char ch): Determines whether a given character is a numeric character atSystem.out.println ("isdigit:" + character.isdigit (' A ')); -System.out.println ("isdigit:" + character.isdigit (' a ')); -System.out.println ("isdigit:" + character.isdigit (' 0 '))); -System.out.println ("-----------------------------------------"); -         //Public Static char touppercase (char ch): Converts the given character to uppercase characters -System.out.println ("toUpperCase:" + character.touppercase (' A ')); inSystem.out.println ("toUpperCase:" + character.touppercase (' a ')); -System.out.println ("-----------------------------------------"); to         //Public Static char tolowercase (char ch): Converts the given character to lowercase characters +System.out.println ("toLowerCase:" + character.tolowercase (' A ')); -System.out.println ("toLowerCase:" + character.tolowercase (' a ')); the     } *}

The results of the operation are as follows:

Java Fundamentals Hardening 69: Character Overview of basic type wrapper classes and character common methods

Related Article

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.