如何取到倒数第二个.的位置
//通过两个lastIndexOf取到倒数第二个.的位置,然后获取包名,因为".bean.Class"是固定的
String clas = "com.test.bean.DocumentCatalogDAO";
String result = clas.substring(0, clas.lastIndexOf (".", clas.lastIndexOf(".") - 1)) + ".dao";
result结果为com.test.dao
---------------------------------------
java 保留小数点后2位
比如 0 --> 0.00 0.566 -> 0.56 1 -->1.00 199.8--> 199.80
System.out.println(String.format("%.2f", f));