标签:
No.
|
数据类型
|
大小/位
|
可表示的数据范围
|
1
|
long(长整数)
|
64
|
-9223372036854775808 ~ 9223372036854775807
|
2
|
int(整数)
|
32
|
-2147483648 ~ 2147483647
|
3
|
short(短整数)
|
16
|
-32768~32767
|
4
|
byte(位)
|
8
|
-128 ~ 127
|
5
|
char(字符)
|
2
|
0 ~ 255
|
6
|
float(单精度)
|
32
|
-3.4E38(-3.4´1038) ~ 3.4E38(3.4´1038)
|
7
|
double(双精度)
|
64
|
-1.7E308(-1.7´10308)~ 1.7E308(1.7´10308)
|
默认值
No.
|
数据类型
|
默认值
|
1
|
byte
|
(byte)0
|
2
|
short
|
(short)0
|
3
|
int
|
0
|
4
|
long
|
0L
|
5
|
float
|
0.0f
|
6
|
double
|
0.0d
|
7
|
char
|
\u0000(空,‘‘)
|
8
|
boolean
|
false
|
byte b=8;
short s=100;
int i=2;
long v=1000;
char ch1=‘a‘;
char ch2=97;
System.out.println("ch1= "+ch1);
System.out.println("ch2= "+ch2);
No.
|
转义字符
|
描述
|
No.
|
转义字符
|
描述
|
1
|
\f
|
换页
|
2
|
\\
|
反斜线
|
3
|
\b
|
倒退一格
|
4
|
\‘
|
单引号
|
5
|
\r
|
归位
|
6
|
\"
|
双引号
|
7
|
\t
|
制表符Tab
|
8
|
\n
|
换行
|
char ch1=‘\"‘;
char ch2=‘\\‘;
System.out.println("ch1= "+ch1);
System.out.println("ch2= "+ch2);
System.out.println("\"Hello World\"");
结果:
ch1= "
ch2= \
"Hello World"
double num1=3.14; float num2=7.3F; System.out.println("num1="+num1); System.out.println("num2="+num2);
boolean flag = true; System.out.println("flag ="+flag);
结果:flag =true;
标签:
原文地址:http://www.cnblogs.com/liunanjava/p/4237786.html