Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道我可以做一个循环,但是我如何让它同时遍历其中的两个???另外,我不知道列表的大小,所以我不能使用 for 循环。相反,可能需要使用一个while循环......它会是一个大布尔表达式吗?
我会尽我所能,感谢一些想法。
这是用两个迭代器完成的:
for (Iterator<String> it1 = list1.iterator(), it2 = list2.iterator(); it1.hasNext() && it2.hasNext();) { final String s1 = it1.next(), s2 = it2.next(); // stuff to do }