java-basic Data type extension (its wrapper class)

Source: Internet
Author: User

1. Object wrapper classes for basic data types

BYTE byte

Short Short

int Integer

Long Long

float float

Double Double

Char Character

Boolean Boolean

2. The most common effect of the basic data type Object wrapper class:

is to convert between the base data type and the string type.

2.1 A method of turning a basic data type into a string. Xxx.tostring (base data type value)

Basic data type + ""

The base data type. toString (base data type value);

such as: Integer.tostring (34);//convert 34 integers into "34";

2.2 The way the string is converted to the base data type. Xxx.parsexxx (String)

xxx a = xxx.parsexxx (String);

int a = Integer.parseint ("123");//Must be added ""

Boolean B = Boolean.parseboolean ("true")

Integer i = new Integer ("123");

int num = I.intvalue ();

3. Input Conversion method

The decimal is converted into another binary.
Xxx.tobinarystring (decimal value);
Xxx.tohexstring (decimal value);
Xxx.tooctalstring (decimal value);

Other binary turns into decimal.
Xxx.parseint (String,radix);

New features that occur after the 4.jdk1.5 version.

integer x = new Integer (4);

Integer x = 4;//Auto-boxing. New Integer (4)

x = x/* X.intvalue () */+ 2;//x+2:x for automatic unboxing. into an int type. and 2 for addition operations.
And then the boxing is assigned to X.

java-basic Data type extension (its 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.