[Javase] Basic data type Object wrapper class

Source: Internet
Author: User
Tags binary to decimal

According to the Java Object-oriented principle, each basic type has a corresponding wrapper class

BYTE byte

Short Short

int Integer

Long Long

Boolean Boolean

float float

Double Double

Char Character

The most common function is the conversion of the base type to string string types

Turn into a string: wrapper object . toString ()

The string is converted to the base type: wrapper class . ValueOf ()

decimal-to-binary: Call integer.tobinarystring ()

Decimal to 16 binary: Call integer.tohexstring ()

Binary to decimal: Call integer.parseint ("binary", 2)

Hexadecimal to decimal: Call integer.parseint ("hex", 16)

Automatic Boxing

Integer x=4, numbers of type int are automatically boxed into an integer object

Automatic unpacking

X=x+2,anInteger object is automatically disassembled into an int type for calculation

When the value is within the byte range, no new space will be opened for the new feature

Integer a=128

Integer b=128

SYSO (a==b)// normal false at this time

Integer a=127

Integer b=127

SYSO (a==b)// special True at this time

[Javase] Basic data type Object wrapper 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.