Java Fundamentals Hardening 65: Introduction of basic type wrapper classes

Source: Internet
Author: User

1. Basic type Packing class overview

(1) The advantage of encapsulating a basic data type as an object is that more functional methods can be defined in the object to manipulate the data.

(2) One of the most common operations: a conversion between a basic data type and a string.

(3) Correspondence of basic types and packaging classes

byte, short, Integer, Long, Float, Double, Character, Boolean

In order to perform more operations on the basic data types and to operate more conveniently, Java provides the corresponding class type--------wrapper class type for each of the basic data types.

2. Case Introduction:

1  Packagecn.itcast_01;2 3 /*4 * Demand 1: I ask you to put 100 of this data binary, octal, hexadecimal calculation out5 * Demand 2: I ask you to determine whether a data is within the range of int. 6 * First of all you know the scope of int is how big?7  * 8 * For more operations on basic data types and easier operation, Java provides the corresponding class type for each of the basic data types. The wrapper class type. 9 * byte byte Ten * Short   short One * int Integer  A * Long long  - * Float float  - * Double double  the * Char Character  - * Boolean boolean  -  *  - * Used for conversions between basic data types and strings.  +  */ -  Public classIntegerdemo { +      Public Static voidMain (string[] args) { A         //No, the trouble is coming. at         //Public static String tobinarystring (int i) -System.out.println (integer.tobinarystring (100)); -         //Public static String tooctalstring (int i) -System.out.println (integer.tooctalstring (100)); -         //Public static String tohexstring (int i) -System.out.println (integer.tohexstring (100)); in  -         //Public static final int max_value to System.out.println (integer.max_value); +         //Public static final int min_value - System.out.println (integer.min_value); the     } *}

Operation Result:

Java Fundamentals Hardening 65: Introduction of basic type wrapper classes

Related Article

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: 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.