iterator不能放在循环里,每次都会获得一个新的迭代器,导致死循环。
要先获取迭代器,然后对迭代器循环。
public static void main(String[] args) {
//正确
Iterator<String> it = getList().iterator
iterator不能放在循环里,每次都会获得一个新的迭代器,导致死循环。
要先获取迭代器,然后对迭代器循环。
public static void main(String[] args) {
//正确
Iterator<String> it = getList().iterator