Java集合中,isEmpty()与size()==0的区别(时间复杂度)。

在进行集合判空时,能用Collection.isEmpty(testList)的就不要用testList.size(),isEmpty不仅可以判断集合是否为null,在时间复杂度上也更优秀。 sonar规范这样描述: Collection.isEmpty() should be used to test for emptiness Using Collection.size() to test f
相关文章
相关标签/搜索