|
type name |
Byte space |
range |
Integer |
byte |
1 |
-2 . 7 to 2 . 7 -1 to 127 or -128 |
|
short |
2 |
-2 15 to 2 15 -1 |
|
int |
4 |
-2 31 is to 2 31 is -1 |
|
long |
8 |
-2 63 is to 2 63 is -1 |
Float |
float |
4 |
Single precision, less precision fractional part of |
|
double |
8 |
Double precision fractional part is large and the operation value |
character |
char |
2 |
0-65535 as a sign bit less so than twice as large as int |
Boolean |
boolean |
1 |
True true false false |
float and double have a problem in terms of our most decimal conversion binary bits are infinite, the lack of accuracy. In the latter would solve api java
Then you can use the following test
package com.tedu.basic; //测试取值范围 public class Test1_Scope { public static void main(String[] args) { byte bmax = Byte.MAX_VALUE; byte bmin = Byte.MIN_VALUE; //打印变量的值快捷键alt+/ System.out.println(bmax);//127 System.out.println(bmin);//-128 short smax = Short.MAX_VALUE; short smin = Short.MIN_VALUE; System.out.println(smax);//32767 System.out.println(smin);//-32768 //int Integer int imax = Integer.MAX_VALUE; int imin = Integer.MIN_VALUE; System.out.println(imax);//2147483647 System.out.println(imin);//-2147483648 //long Long long lmax = Long.MAX_VALUE; long lmin = Long.MIN_VALUE; System.out.println(lmax);//9223372036854775807 System.out.println(lmin);//9223372036854775808 //float Float float fmax = Float.MAX_VALUE; float fmin = Float.MIN_VALUE; System.out.println(fmax);//3.4028235E38 System.out.println(fmin);//1.4E-45 //double Double double dmax = Double.MAX_VALUE; double dmin = Double.MIN_VALUE; System.out.println(dmax);//1.7976931348623157E308 System.out.println(dmin);//4.9E-324 System.out.println(); char c = 'h';//"" 字符串 ''字符 char c2 = '0'; char c3 = '我';//char可以存一个汉字 char c4 = 200; // character type, the final output is a character 98 // able to convert into character b, // char type because the underlying code table will be checked ascii // ascii code table defines the character corresponding to 0-127, // ascii code numbers are by no table? Character to deal with System.out.println (c4); //? } }
Encoding - the digit character conversion process is the conversion rule - code table
ASCLL (Astor code table) 0-127 although it occupies half a byte or a byte
ISO8859-1 (Western European code table) one byte 0-255
GB2312 (English), BIG5 (Traditional) 2 bytes
GBK (GB code) // State's own coding
UnIcode coding system which has a lot code table (Unicode) are specific (utf-8, utf-16, utf-32, etc.)
Escape character:
\ T space \ r carriage return \ n line feed, etc.