2016-06-28
Integral type
1 bytes of 8 bits
1 byte1 byte -128~127
2 Short2 byte -32768~32767
3 int4 bytes plus or minus 2 billion more use the most
4 Long8 byte is especially large, when int is not enough, it will use long
Packageday06; Public classTestFloat { Public Static voidMain (string[] args) {intI1=1;//declaring an int type variable intI2=3; floatf1=1f;//declaring a float type variable floatF2=3f; floatRESULT1,RESULT2;//variables that record resultsRESULT1=i1/i2;//The result should be 0 .RESULT2=F1/F2;//The result should be 0.333333 .System.out.println ("Result1=" +RESULT1); System.out.println ("Result2=" +result2); }}
Character type
5 char occupies 2 bytes, in Unicode encoding format, supports Chinese
Packageday06; Public classTestchar { Public Static voidMain (string[] args) {CharChar1= ' a '; CharChar2= ' A ' +1; CharChar3= ' A '-1; System.out.println ("Char1=" +char1); System.out.println ("Char2=" +char2); System.out.println ("Char3=" +char3); //in the Unicode encoding table ' a B }}
Floating point Type
6 float 4 byte single precision
7 Double8 byte double precision with up to
Boolean type
8 Boolean
True True
False false
package day06; public class Testboolean { static void main (string[] args) {boolean b=true ; // declares a Boolean type variable b if (b) {System.out.println ( "b=" +b+ "satisfies the condition, if statement executes" ); else {System.out.println ( "b=" +b+ "The condition is not met, the Else statement executes" ); } }}
Resources
[1] Java Easy Start Classic tutorial "full version"
Java Section No. 06 eight Big data types