试一下这个,我认为比较贴题。运行看看

firefox99 (firefox99)
import java.util.*;
public class LinkedListEnumeration extends LinkedList implements Enumeration{
private Iterator it;
private LinkedList list;
LinkedListEnumeration(LinkedList llist){
it = llist.iterator();
list = llist;
}
public boolean hasMoreElements(){
return it.hasNext();
}
public Object nextElement(){
return it.next();
}
public String toString(){
return "["+list+"]";
}
public static void main(String[] args){
LinkedList l1 = new LinkedList();
l1.add("this");l1.add("is");l1.add("a");l1.add("test");
LinkedListEnumeration le = new LinkedListEnumeration(l1);
System.out.println("travel the content in this List is:");
while(le.hasMoreElements())
System.out.print(le.nextElement() + " ");
System.out.println();
System.out.println(le);

}
}
(#43550@0)
2001-4-11 -05:00

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

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

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