看板java
标 题关於NoSuchElementException的问题
发信站KKCITY (Sat Apr 14 16:45:15 2007)
转信站ptt!ctu-reader!ctu-peer!ctu-gate!news.nctu!news.ntu!news.au!zoonews.ee
底下我自己写了一个小的程式(有关於hashtable的程式)
不知道为什麽会有NoSuchElementException发生
有人可以解说一下吗,,,谢谢!!
import java.util.*;
public class Main {
public static void main(String[] args) {
try{
Hashtable ht = new Hashtable();
ht.put("key1","E1");
ht.put("key2","E2");
ht.put("key3","E3");
Enumeration ek=ht.keys();
Enumeration ev = ht.elements();
while(ek.hasMoreElements())
{
System.out.println((String)ev.nextElement());
}
}
catch ( NoSuchElementException e1)
{
System.out.println("Exception happens" );
}
finally
{
System.out.println("ok") ;
}
}
}
--
┌─────◆KKCITY◆─────┐▇─┐ 优质连线服务隆/重/豋/场!!
│ bbs.kkcity.com.tw │┴ └─▇ KKADSL 带你环游全世界
└──《From:220.143.231.122
》──┘ KKADSL ┴ http://adsl.kkcity.com.tw
--