Data overflow of Java

Source: Internet
Author: User

Integer is a wrapper class in Java that can be used for both string and integer conversions, as well as for unpacking and boxing
 PackageABC; Public classa{ Public Static voidMain (string[] args) {//TODO auto-generated Method Stub//get the maximum value for shaping        intmax=Integer.max_value; //Maximum output valueSYSTEM.OUT.PRINTLN ("Maximum value for shaping is" +max); //maximum value plus 1SYSTEM.OUT.PRINTLN ("Maximum value for shaping is +1" + (max+1)); //The maximum value plus 2 becomes a long typeSYSTEM.OUT.PRINTLN ("Maximum value for shaping is +1" + (max+1)); //cast to long typeSystem.out.println ("The maximum value for shaping is +2" + ((Long) max+2)); }}

Run

The maximum value for shaping is the maximum value of 2147483647 shaping is the maximum value of +1-2147483648 shaping is +1-2147483648 The maximum value for shaping is +22147483649

Character and Integer conversions: Char type assignment is enclosed in a pair of single quotation marks (");

 PackageABC; Public classB { Public Static voidMain (string[] args) {//TODO auto-generated Method Stub//Defining characters        CharCh1= ' a '; //define character, Integer to character        CharCh2=1; System.out.println ("Ch1=" +ch1); System.out.println ("Ch2=" +CH2); }}

Run

ch1=a;ch2=a;

Common escape characters:

\f: Page Change

\b: one step backwards

\ n: Line break

\ t: Tab tab

\ r: Return position

\ \: Backslash

\ ': Single quote

\ ": Double quotation marks

Application of escape characters:

 PackageABC; Public classC { Public Static voidMain (string[] args) {//TODO auto-generated Method Stub//Defining escape characters        Charch1= ' \ "'; //Defining escape characters        Charch2= ' \ \ '; System.out.println ("CHA1" +ch1); System.out.println ("CHA2" +CH2); //Direct output Escape characterSystem.out.println ("\" Hello\ ""); }}

Run

CHA1"cha2" Hello "

Data overflow of 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.