Java 13-3 int type of wrapper package integer

Source: Internet
Author: User


1, an overview of the integer

Requirement 1: put 100 binary, octal, hexadecimal calculation of this data
Requirement 2: Determine whether a data is within the range of int.
First you need to know how big the int is?

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

Class type wrapper class type

BYTE byte
Short Short
int Integer
Long Long
float float
Double Double
Char Character
Boolean Boolean

Used for conversions between the base data type and the String.

1  public classIntegerdemo {2  public Static voidmain (string[] Args) {3 //no, The trouble is Coming.4 //public static String tobinarystring (int i)5System.out.println (integer.tobinarystring (100));6 //public static String tooctalstring (int i)7System.out.println (integer.tooctalstring (100));8 //public static String tohexstring (int i)9System.out.println (integer.tohexstring (100));Ten  one //public static final int max_value a System.out.println (integer.max_value); - //public static final int min_value - System.out.println (integer.min_value); the } -}


2, the construction method of Integer:
Public Integer (int Value)
Public Integer (String S)
Note: This string must be made up of numeric characters

1  public classIntegerdemo {2  public Static voidmain (string[] Args) {3 //Mode 14 inti = 100;5Integer II =NewInteger (i);6System.out.println ("ii:" +ii);7 8 //Mode 29String s = "100";Ten //NumberFormatException one //String s = "abc"; aInteger III =NewInteger (s); -System.out.println ("iii:" +iii); - } the}

Java 13-3 int type of wrapper package integer

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