public interface Enumeration<E> {
/**
* Tests if this enumeration contains more elements.
*
* @return <code>true</code> if and only if this enumeration object
* contains at least one more element to provide;
* <code>false</code> otherwise.
*/
boolean hasMoreElements();
/**
* Returns the next element of this enumeration if this enumeration
* object has at least one more element to provide.
*
* @return the next element of this enumeration.
* @exception NoSuchElementException if no more elements exist.
*/
E nextElement();
}
------解决方案-------------------- 不知道楼上两位有没有编译过,先不看第一行 奇葩的写法,(正常人写都会声明成List接口),第二行FileInputStream的Iterator的引用怎么能够指向一个Iterator<String>的对象?
后面的代码是匿名类实现了Enumeration接口
Java code
public interface Enumeration<E> {
/**
* Tests if this enumeration contains more elements.
*
* @return <code>true</code> if and only if this enumeration object
* contains at least one more element to provide;
* <code>false</code> otherwise.
*/
boolean hasMoreElements();
/**
* Returns the next element of this enumeration if this enumeration
* object has at least one more element to provide.
*
* @return the next element of this enumeration.
* @exception NoSuchElementException if no more elements exist.
*/
E nextElement();
}
------解决方案--------------------
------解决方案--------------------
------解决方案-------------------- ArrayList<String> al = new ArrayList<String>();
final Iterator<FileInputStream> it = al.iterator(); 这行代码编译有问题啊,Iterator<FileInputStream>泛型类型String不一致
------解决方案--------------------