JAVA面试题
在学习JAVA过程中会整理一些面试题,定期更新
1银行业务如何表示(钱)
//float 有限 离散 舍入误差 大约 接近但不等于
//double
//最好避免完全使用浮点数进行比较
使用JAVA中的BigDecimol 数学工具类进行表示
因为:
float f =0.1f;
double d=1.0/10;
System.out.println(f==d);//fasle
而
float d1=2333131313131323f;
float d2=d1+1;
System.out.println(d1==d2);//true
出现了大数吃小数现象
====================================================
2定义相同为何输出不同
String sa=new String("hello world");
String sb=new String("hello world");
System.out.println(sa==sb);//flase
String sc="hello world";
String sd="hello world";
System.out.println(sc==sd);//ture
要从对象,内存分析
3. 如何最快运算2*8
/*<< 左移 *2
>>右移 /2
正常运算是 2*8=2*2*2*2
0000 0000 0
0000 0001 1
0000 0010 2
.............
0000 1000 8
0001 0000 16
快速运算 System.out.println(2<<3);//输出16