1 package debug; 2 3 class demo { 4 /* 5 * 定义八种基本数据类型,如下 6 */ 7 8 public static void main(string[] args) { 9 //define char type 10 char a = '1'; //字符类型用单引号 11 system.out.println(a); 12 13 //define string type 14 string text = "hello world"; //字符串类型用双引号 15 system.out.println(text); 16 17 //define float type 18 float f = 1.03f; //单精度浮点类型后面必须要带上f或者f,默认用f 19 system.out.println(f); 20 21 //define double type 22 double d = 1.345; //浮点类型默认为双精度,所以如果定义的是doule类型,后面就不需要再带上f 23 system.out.println(d); 24 25 //define short type 26 short s = 100; 27 system.out.println(s); 28 29 //define int type 30 int i = 101; 31 system.out.println(i); 32 33 //define long type 34 long l = 10000000000l; //定义长整型后面必须要带上l或者l,默认用l 35 system.out.println(l); 36 37 //define byte type 38 byte a1 = 102; 39 system.out.println(a1); 40 41 //define boolean 42 boolean b = false; 43 system.out.println(b); 44 45 46 } 47 48 }
输出如下:
1 1 2 hello world 3 1.03 4 1.345 5 100 6 101 7 10000000000 8 102 9 false
如对本文有疑问, 点击进行留言回复!!
SpringBoot引用阿里easyexcel,Excel导出返回浏览器下载
HashMap、Hashtable、ConcurrentHashMap三者间的异同
解决RecycleView 中Item包含Edittext时,滑动view复用导致数据错乱的问题
多线程、同步工作原理、死锁案例、Lock接口、线程的生命周期的讲解及实现
网友评论