有点问题,更正一下

firefox99 (firefox99)
import java.util.*;
class LinkedListEnumerationNew{
private Iterator itor;
private LinkedList lklist;
private class LEnumeration implements Enumeration{
LEnumeration(){
itor = lklist.iterator();
}
public boolean hasMoreElements(){
return itor.hasNext();
}
public Object nextElement(){
return itor.next();
}
}
public Enumeration elements(){
return new LEnumeration();
}
LinkedListEnumerationNew(LinkedList ll){
lklist = ll;
}
// option methods
public String toString(){
return ""+lklist;
}
public boolean add(Object o){
return lklist.add(o);
}
}

public class TestSamples{
public static void main(String argc[]){
LinkedListEnumerationNew le = new LinkedListEnumerationNew(new LinkedList());
le.add("this");
le.add("is");
le.add("test");
System.out.println(le);
Enumeration enum = le.elements();
while(enum.hasMoreElements())
System.out.println(enum.nextElement()+" ");
}
}
(#45440@0)
2001-4-14 -05:00

回到话题: 问题进一步具体化...奖品也

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT杂谈

URL:   
http://www.rolia.net/zh/post.php?f=0&p=45440