公司代码学习笔记

String.format

return String.format("https://%s", "www.baidu.com");
此处的%s 相当于占位符
返回结果为 ”https://www.baidu.com“

String.format("%05d", (++integer));
不足5位数 左侧补02012 -> 02012

File.separator

File.separator 的作用相当于 ' \  '

ObjectUtils.defaultIfNull(XXX,0)

当xxx为null 时 设置为0或其它指定值

 Integer integer = ObjectUtils.defaultIfNull(shipmentBoxDao.getMaxBoxNo(selectBoxNoCount), 0);

【java8】stream的.findAny().orElse (null) 是什么意思

findAny()是集合中的意条件的一个,orElse(NUll)是如果没有就返回null。

Arrays.stream(DepotCellAreaEnum.values()).filter(item -> item.code.equals(code)).findFirst().orElse(null);
//查询第一个 没有的返回null值

//过滤空值
long count = list.stream().filter(StringUtils::hasLength).count();

HashMap的默认值

HashMap的默认初始容量为16,默认加载因子为0.75,默认阈值为:16*0.75=12

当HashMap的size超过阈值,HashMap的容量就会改变(扩大为原始大小的两倍)

猜你喜欢

转载自blog.csdn.net/Crush_kylin/article/details/119083371
今日推荐