Lang packet Knowledge point (i) lang Package and packaging class

Source: Internet
Author: User
Tags character classes

Lang Package Introduction: 1, Java.lang package is a Java built in a basic package, which contains a series of programs often used in the class; 2,by default, each Java program imports the package automatically, so you do not need to explicitly specify it in your program. package classes in the Lang package:Java provides a series of wrapper classes to manipulate raw data types as objects. In the Java.lang package, there is an appropriate wrapper class for each raw data type.

Each wrapper class has a the static valueof methodThat is used to string into the appropriate wrapper classThe object.
    // If the conversion fails, a NumberFormatException exception    will be thrown String str = "+";     = byte.valueof (str);     = short.valueof (str);     = integer.valueof (str);     = long.valueof (str);

In addition to the Boolean and character classes, other wrapper classes have a static Parsexxx method (XXX refers to a specific data type), which is used to convert the string to the corresponding raw data type value .

     The pasexxx method of each wrapper class is called separately to convert the string, and if the conversion fails, the exception    is reported int i = integer.parseint (str);      Short s = short.parseshort (str);     byte b = byte.parsebyte (str);     long L = long.parselong (str);     float f = float.parsefloat (str);     double d = double.parsedouble (str);

Common methods in the character class

BooleanIsletter (CharCh//determine if the character ch is an English letterBooleanIsDigit (CharCh//determines whether the character Ch is a number between 0~9BooleanIsuppercase (CharCh//determines if the character ch is in uppercase formBooleanIslowercase (CharCH)//determines if the character ch is in lowercase formBooleanIswhitespace (CharCh//determine if the character ch is a space or line break//The above methods are static methods, can be called directly through the class name, the return value isis a Boolean, or False if True is returned.

Title:

There are character arrays: char[] Chararray = {' * ', ' 7 ', ' B ', ', ' A '}; What are each character, respectively?

 Public classCharacterdemo { Public Static voidMain (string[] args) {Char[] Chararray = {' * ', ' 7 ', ' B ', ', ' A '};  for(inti = 0; i < chararray.length; i++) {      if(Character.isdigit (Chararray[i])) {System.out.println (Chararray[i]+ "is a number. "); }      if(Character.isletter (Chararray[i])) {System.out.println (Chararray[i]+ "is a letter. "); }      if(Character.iswhitespace (Chararray[i])) {System.out.println (Chararray[i]+ "is a space. "); }      if(Character.islowercase (Chararray[i])) {System.out.println (Chararray[i]+ "is the lowercase form. "); }      if(Character.isuppercase (Chararray[i])) {System.out.println (Chararray[i]+ "is in uppercase form. "); }    }  }}

Lang packet Knowledge point (i) lang Package and packaging class

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.