2020
12-14
12-14
JAVA Iterator 转成 List 的操作
List转到Iterator容易,JDK本身就支持,反过来的实现方式如下:1.使用ApacheCommonCollections2.自己实现的方法转换3.Guaa实现转换方式1:#ApacheCommonsCollections:importorg.apache.commons.collections.IteratorUtils;Iterator<Element>myIterator=//someiteratorList<Element>myList=IteratorUtils.toList(myIterator);方式2:或者自己转换publicstatic<T>List<T>copyIterator(Iterator<T>iter){List<T>...
继续阅读 >