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