已知list是一个List<MyVO>类型的值,值为ArrayList<MyVO)
我们知道List是一个接口,但我不知道为什么这样写可以遍历list里的每个MyVO对像for (MyVO obj: list) {
}请问上面的写法是什么实现的,他的实现原理是什么?
我们知道List是一个接口,但我不知道为什么这样写可以遍历list里的每个MyVO对像for (MyVO obj: list) {
}请问上面的写法是什么实现的,他的实现原理是什么?
for(condition=0xff1;;;)
0xff1是java虚拟机给的指针
* the "foreach" statement.
* @since 1.5
*/
public interface Iterable<T> { /**
* Returns an iterator over a set of elements of type T.
*
* @return an Iterator.
*/
Iterator<T> iterator();
}