美文网首页
代码使用累积

代码使用累积

作者: work1Y | 来源:发表于2017-10-17 09:50 被阅读0次

1.将对象转化成json字符串
JsonUtils.toJsonString(obj)
关键字:jackson,objectMapper

2.List截取子链表subList
List<E> List.subList(int fromIndex , int toIndex);
它返回的是原list中[fromIndex,toIndex)之间的一部分视图,靠原来的list支持,"非结构性修改"都会影响到彼此。

3.将list中的项以逗号分隔,返回字符串
Joiner.on(",").join(list);
关键字:Joiner,Iterable,append

4.两个对象进行属性的拷贝
BeanUtils.copyProperties();
虽减少了代码,但是效率比getter、setter要低.
尽量使用spring中BeanUtils.copyProperties() 而不是Apache的。

5.获取接口执行时间
System.currentTimeMillis();
结束时间-开始时间

相关文章

网友评论

      本文标题:代码使用累积

      本文链接:https://www.haomeiwen.com/subject/egbruxtx.html