Java Record -30-wrapper class

Source: Internet
Author: User
Tags comparable

Wrapper class (Wrapperclass), for packages of native data types.

1. Java provides 8 types of native data. However, in many places where the object type is required for use, and the native data type is not an object, the native data type needs to be wrapped as an object type for use.

2. Java provides wrapper classes for 8 native data types. A wrapper class object that hosts the value of the specific native data type.

3.  We can manipulate the native data type as if it were an object-type operation. All packaging classes ( 8 java.lang pack.

4. the eight wrapper classes in Java are:Byte, short,Integer,Long ,Float,Double,Character , Boolean. They are all used the same way, enabling bidirectional conversions of native data types and wrapper types.


Usage examples:

Public static void main (string[] args) {

int i = 3;

Integer integer = New Integer (i);

int II = Integer.intvalue ();

System. out . println (i = = II);

}


C Lass Integer

Java.lang.Object

Java.lang.Number

Java.lang.Integer

All implemented Interfaces:

Serializable, comparable<Integer>
Public final Class Integer extends Number Implementscomparable<Integer>

The Integer class wraps a value of the primitive type int in an object. An object of type Integer contains a single field whose type is int.

In addition, the This class provides several methods for converting an int to a string and a string to an int., as well as othe R constants and methods useful when dealing with an int.



Java Record -30-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.