\r | 相当于按下回车键 |
\n | 换行 |
\t | 制表符 |
\b | 表示退格键 |
\' | 相当于单引号' |
\'' | 相当于双引号"" |
\\ | 相当于斜杠\ |
package com.lqh.chapter01; public class _03BasicType { public static void main(String[] args) { byte a = 100; short b = 1000; int c = 100; long d = 100L;//末尾要加上大写“L”或者小写“l”,不建议使用小写“l” float e = 520.1314f;//末尾要加上大写“F”或者小写“f” double f = 13.14; boolean g = true; char h = 'h';//可以是单个字母 char h2 = '红';//可以是单个中文 char h3 = '\u3222';//可以是Unicode字符,\u3222代表㈢ char h4 = '\n';//可以是转义字符,\n代表换行 char h5 = 33;//可以是ASCII码,33代表! System.out.println(a); System.out.println(b); System.out.println(c); System.out.println(d); System.out.println(e); System.out.println(f); System.out.println(g); System.out.println(h); System.out.println(h2); System.out.println(h3); System.out.print(h4); System.out.println(h5); //MIN_VALUE:最小值, MAX_VALUE:最大值 System.out.println("byte取值范围为:"+Byte.MIN_VALUE+"~"+Byte.MAX_VALUE); System.out.println("short取值范围为:"+Short.MIN_VALUE+"~"+Short.MAX_VALUE); System.out.println("int取值范围为:"+Integer.MIN_VALUE+"~"+Integer.MAX_VALUE); System.out.println("long取值范围为:"+Long.MIN_VALUE+"~"+Long.MAX_VALUE); System.out.println("float取值范围为:"+Float.MIN_VALUE+"~"+Float.MAX_VALUE); System.out.println("double取值范围为:"+Double.MIN_VALUE+"~"+Double.MAX_VALUE); } }
输出结果为:
100
1000
100
100
520.1314
13.14
true
h
红
㈢!
byte取值范围为:-128~127
short取值范围为:-32768~32767
int取值范围为:-2147483648~2147483647
long取值范围为:-9223372036854775808~9223372036854775807
float取值范围为:1.4E-45~3.4028235E38
double取值范围为:4.9E-324~1.7976931348623157E308