wrapper classes in Java

Source: Internet
Author: User

Wrapper type for eight basic data types in Java: Basic data type wrapper type Bytejava.lang.byte;shortjava.lang.short;intjava.lang.integer;longjava.lang.long ;floatjava.lang.float;double      java.lang.double;booleanjava.lang.boolean; charjava.lang.character;/* to the Java.lang.Integer; type for example, to explain eight kinds of types. */public class integertest02{public static void main (String[] args) {// Gets the maximum and minimum values of type int System.out.println ("int min:"  + integer.min_value); SYSTEM.OUT.PRINTLN ("int max:"  + integer.max_value);//push byteSystem.out.println with int ("Byte min:"  +  byte.min_value); System.out.println ("Byte max:"  + byte.max_value);//Create an object of type integer integer i1 = new  integer ( //int--> integerinteger i2 = new integer),  //("123"); String --> integersystem.out.println (I1);  //10system.out.println (I2);  //123//The following program compilation can be passed. However, it is reported as abnormal when running. Numeric formatting exceptions.//Although you can convert a string to an Integer type, the string must also be a "numeric string."//integer i3 = new  Integer ("ABCD");  //numberformatexceptioninteger Common Method:public class intergertest{     public static void main (String[] args) {    //int--" interger  Basic Data Type-"reference data type     interger i1=new integer (TEN);     integer i1=integer.valueof (Ten);    //    int i2=  I1.intvalue ();    //string-->integer    integer i3=new  Integer ("ten");     integer i4=integer.valueof ("Ten");    //**  string-("Int    int i4=integer.parseint");     //*****string- >>double    double i5=double.parsedouble ("30.111");//convert decimal of type int to 16 binary string  s2 = integer.tohexstring (10); SYSTEM.OUT.PRINTLN (S2);  //a//converts decimal of type int to 8 binary string s3 = integer.tooctalstRing (10); System.out.println (S3);  //12     }}


This article is from the "Gaogaozi" blog, make sure to keep this source http://hangtiangazi.blog.51cto.com/8584103/1662485

wrapper classes in Java

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.