代码:
String url ="www.xxx.com/s?index=%d"; for(int i=1;i<=5;i++) { String format = String.format(url, i); System.out.println(format); }
输出结果:
www.xxx.com/s?index=1 www.xxx.com/s?index=2 www.xxx.com/s?index=3 www.xxx.com/s?index=4 www.xxx.com/s?index=5
String.valueof()
String 类别中已经提供了将基本数据型态转换成 String 的 static 方法 ,也就是 String.valueOf() 这个参数多载的方法
java8 .stream().map().collect() 的用法
学习链接:https://blog.csdn.net/weixin_40001125/article/details/105766744
collect中的内容:https://blog.csdn.net/dandandeshangni/article/details/109706151
判断字符串空的几种方法
BigDecimal.setScale用法总结
学习链接:https://blog.csdn.net/qq_39101581/article/details/78624617
1. ROUND_DOWN
BigDecimal b = new BigDecimal("2.225667").setScale(2, BigDecimal.ROUND_DOWN); System.out.println(b);//2.22 直接去掉多余的位数
2. ROUND_UP
BigDecimal c = new BigDecimal("2.224667").setScale(2, BigDecimal.ROUND_UP); System.out.println(c);//2.23 跟上面相反,进位处理
https://blog.csdn.net/dandandeshangni/article/details/109706151