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.
我们都知道这段代码:
ArrayList<String> str1 = new ArrayList<String>(); for(String str: str1) { // code goes here }
这个增强的 for 循环使用 Iterable 而不是Iterator遍历。但我没有看到ArrayListextends Iterable。谁能告诉我为什么会发生这种情况?
Iterator
ArrayList
Iterable
ArrayList扩展AbstractList实现Iterable
AbstractList