First, Packaging class
The integer, long, and short classes in the >>java.lang package encapsulate the basic data type int, long, and short into a single class. These classes are subclasses of number.
>> Construction Method
The >>>integer (int number) method takes an int variable as a parameter to get an Integer object
The >>>integer (String str) method takes a string variable as a parameter to get an Integer object
>> Common methods
common methods of the integer class
method |
return value |
feature Description |
bytevalue () |
byte |
Returns the value of this integer in byte type |
compareTo (in Teger anotherinteger) |
int |
compares two integer objects on a number. Returns 0 if two objects are equal, or a negative value if the number of the calling object is less than Anotherinteger, or a positive value if greater than |
equals (Object integerobj) | Td>boolean
To compare whether this object is equal to the specified object |
intvalue () |
int |
returns this integer object in type int |
shortvalue () |
short |
returns this integer object in short type |
toSt Ring () |
string |
Returns a String object representing the integer value |
valueOf (String str) |
Integer |
Returns an integer object that holds the specified string value |
parseint (String str) |
int |
Rebate Returns the equivalent integer value of the number contained in the string specified by str |
The >>>tobinarystring () method converts an integer type to a binary string
The >>>tohexstring () method converts an integer type to a hexadecimal string
The >>>tooctalstring () method converts an integer type to an octal string
>> Constants
>>>max_value: Represents the desired maximum value for the int type, which is 231-1
>>>min_value: Represents the minimum value that is desirable for an int type, which is-231
>>>size: The number of digits used to represent the int value in twos complement form
>>>type: class instance representing the base type int
>> Construction Method
The >>>boolean (Boolean value) method creates a Boolean object that represents the value parameter
The >>>boolean (String str) method takes a string variable as a parameter to get the Boolean object. Returns a Boolean object that represents true if the string parameter is not null and equals True when the case is ignored
>> Constants
>>>true: A Boolean object that corresponds to the base value TRUE
>>>false: A Boolean object that corresponds to the base value FALSE
>>>type: class instance of the base type Boolean
>> Construction Method
The >>>byte (byte value) method creates a byte object that can represent the specified byte value
The >>>byte (String str) method creates a Byte object that represents the byte value that is indicated by the string parameter. To use a numeric string variable as an argument, a numberformatexception error will occur
>> Constants
>>>max_value: Represents the desired maximum value for a byte type
>>>min_value: Represents the minimum value that is desirable for a byte type
>>>size: The number of bits used to represent a byte value in twos complement form
>>>type: class instance representing the base type byte
>> Construction Method
>>character (char value) is used to convert a char type data to a Character object
>> Common methods
>>>touppercase (Char ch)
>>>tolowercase (Char ch)
>>>isuppercase (Char ch)
>>>islowercase (Char ch)
>> Constants
>>>connector_punctuation: Returns a byte value that represents the general category "Pc" in the Unicode specification
>>>unassigned: Returns a byte value that represents the general category "Cn" in the Unicode specification
>>>titlecase_letter: Returns a byte value that represents the general category "Lt" in the Unicode specification
>> construction method similar to integer
>> Common methods
>>>isnan (): Returns True if this double value is a non-numeric (NaN) value
>> Constants
>>>max_exponent: Returns an int value that represents the maximum exponent that a finite double variable might have
>>>min_exponent: Returns an int value representing the smallest possible exponent of a finite double variable
>>>negative_infinity: Returns a Double value that represents a constant that holds a negative infinity value of type double
>>>positive_infinity: Returns a Double value that represents a constant that holds a positive infinity value of type double
>> Abstract class number is the parent class of the BigDecimal, BigInteger, Byte, Double, Float, Integer, long, and short classes, and the subclass of number must provide the ability to convert the represented value to Byte, Methods for double, float, int, long, and short
Java Learning Note 05