Wrapper class represented by Java integer

Source: Internet
Author: User

The integer of the Java species is the wrapper type of int

1. Integer is the wrapper type of int, the data type is class and the initial value is null

2. When initializing

  

int i = 1new Integer (1);

3. Automatic packing and unpacking of class

1) Automatic packing

New Integer (1);    // using a normal declarative method Integer i = 1;    // using auto-boxing

2) Automatic Unpacking

Integer num = ten;      // Automatic Boxing System.out.print (num--);    // Automatic Unpacking

3) auto-unpacking and In-box to enjoy the Meta-mode

-128~128 (8bit Numeric) value, The memory will be reused after being boxed (that is, variables with different names 8bit numbers are the same in Memory)

A number other than -128~127, each declaration creates a new object, so the boxed object is not equal even if the unboxing value is the same (= = result is False)

4. The packaging classes in Java

1) Packing class is final type

2) Packaging class Support variable conversion

Byte Java.lang.Byte
Boolean Java.lang.Boolean
Short Java.lang.Short
Char Java.lang.Charactor
Int Java.lang.Integer
Long Java.lang.Long
Float Java.lang.Float
Double Java.lang.Double

5. Methods of the Integer class

1) Construction Method

Integer (int value)        // use number integer (string s)          // number represented by string

2) method

return value Name Function
Type conversions
Byte Bytevalue () Returns a byte type
Double Doublevalue () Returns a double type
Float Floatvalue () ...
Int Intvalue ()
Long Longvalue ()
Short Shortvalue ()
String
String ToString () A String object that represents the value
Static String ToString (int I) A String object that represents the specified integer
Static String toString (int i, int radix) An integer string object that represents the specified cardinality
Static String Tobinarystring (int I) Binary unsigned string
Static String Tohexstring (int I) Hexadecimal unsigned string
Static String Tooctalstring (int I) Octal unsigned string
static int parseint (String S) Convert a string to an integer
static int Reverse (int I) Reverse the order of the bits of the twos complement
static int Rotateleft () Loop left Shift
static int Rotateright ()
Int Hashcode () Return hash code
Int CompareTo (Integer) Compare the values of two Integerd

Wrapper class represented by Java integer

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.