标签:height nbsp highlight rap wrapper width out har java
1.基本数据类型篇
Java中的基本数据类型只有8个:byte、short、int、long、float、double、char、boolean。
包装类型(wrapper class):Boolean,Character,Byte,Short,Integer,Long,Float,Double
占用字节数:
1 int a=10; 2 short b=10; 3 double c=10; 4 float d=10.3f; 5 long e =10L; 6 Integer integer = Integer.valueOf(a); 7 Short short1 = Short.valueOf(b); 8 Double double1 = Double.valueOf(c); 9 Float float2 = Float.valueOf(d); 10 Long long1 = Long.valueOf(e); 11 12 System.out.println(integer); 13 System.out.println(short1); 14 System.out.println(double1); 15 System.out.println(float2); 16 System.out.println(long1); 17 18 System.out.println(integer.intValue()); 19 System.out.println(short1.shortValue()); 20 System.out.println(double1.doubleValue()); 21 System.out.println(float2.floatValue()); 22 System.out.println(long1.longValue());
基础类型常见试题:
<1>如下运行结果:
Integer f1 = 100, f2 = 100, f3 = 127, f4 = 127,f5=128,f6=128; System.out.println(f1 == f2); System.out.println(f3 == f4); System.out.println(f5 == f6);
result: true true
false
标签:height nbsp highlight rap wrapper width out har java
原文地址:https://www.cnblogs.com/wongandy/p/11386176.html