Java Learning Note 05

Source: Internet
Author: User

First, Packaging class

    • Review

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.

    • Integer class

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

Td>boolean
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) 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

    • Boolean class

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

    • Byte class

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

    • Character class

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

    • Double class

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

    • Number class

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

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.