PackageCom.hgd.study;/*** Conversion between basic data types *@authorHutiger **/ Public classdatatypeconversion { Public Static voidMain (string[] args) {}/*** Conversion of small type to large type: * Complete automatic conversion, do not allow the programmer to do the corresponding operation *@paramargs*/ Public Static voidStob () {byteb=100; System.out.println (b); intI=b; System.out.println (i);}/*** Conversion of large type to small type*/ Public Static voidBtos () {/** Large type conversion to small type is called coercion type conversion. Also pay attention to the boundary value of the type*/ inti=100; byteB = (byte) I; System.out.println (b);}/*** int and char type conversion * int to char is coercion type conversion * char to int is auto convert*/ Public Static voidInttochar () {inti=97; CharC= (Char) I; System.out.println (c); CharC1= ' a '; intI1=C1;//The Unicode code for A is assigned to I1 by default in the Java language}}
Java Learning Note: Conversion of Java data types