声明??????????
是这样吗?
Vector的:
Enumeration elements()
Returns an enumeration of the components of this vector.
Vector v = new Vector();
Enumeration e = v.elements()ArrayList的
Iterator iterator()
Returns an iterator over the elements in this list in proper sequence.
是这样吗?
Vector的:
Enumeration elements()
Returns an enumeration of the components of this vector.
Vector v = new Vector();
Enumeration e = v.elements()ArrayList的
Iterator iterator()
Returns an iterator over the elements in this list in proper sequence.
更正一下
上面的
Vector和ArrayList都有
这个方法
Iterator iterator()
Returns an iterator over the elements in this list in proper sequence.所以都可以使用
iterator()
来获得迭代器
Iterator i = v.iterator();ArrayList a = new ArrayList();
Iterator i = a.iterator()
我也是像你一样.但是Iterator是一个abstract class啊.
我用的是JBuilder6
如有错误请指正.
iterator是个抽象类没错.但是你的实例是那个arraylist或者vector中的方法返回的。。这就是多态
我用的是JBuilder6
至于说抽象类的问题,你就当他像是一个接口吧
很多接口还不是类似这样用的?
比如ResultSet就是一个接口了·······
至于你用的JB6,嗯,应该说这种使用的方式跟IDE无关的