3.6 complement

Source: Internet
Author: User

Wrapper class, basic data type, string conversion between each other

Each base data type has a corresponding wrapper type

wrapper classes, basic data types, and string conversions between the three are important when converting between them;

One, String to other

string→ Package Type
1, Integer (String str)
Call the wrapper class with a string parameter construct

string→ Basic data types
☆string→int calling the parseint method of the wrapper class

Second, packaging class to other

→string
Call the ToString method of the wrapper class object

→ Basic types
① calling the Xxxvalue method of the wrapper class
Methods of wrapping classes, related to objects, non-static, without reference

After ②jdk1.5, direct assignment
int i = Integer
Since unpacking

III. basic data types transfer to other

→string
①5 + ""
②str = integer.tostring (i);
Using the parameter tostring method of the wrapper class

→ Packaging
① calling the construct of the wrapper class new
After ②jdk1.5, direct assignment =
Automatic Seal box

Object obj = 10;
This is also an automatic enclosure, which refers to the parent class's reference to the Child class object

integertest

3.6 complement

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.