[問題] 關於enumeration的疑問
我查了enumeration這個類別 他是屬於interface 介面類別
那麼介面類別中的method 不是應該都沒有程式碼?
那麼 請問以下的程式是為何可以running呢?
import java.util.*;
class Ex16_5 {
public static void main(String[] args) {
Hashtable ht = new Hashtable();
ht.put("Server", new String("163.15.40.242"));
ht.put("Client1", new String("163.15.40.243"));
ht.put("Client2", new String("163.15.40.244"));
Enumeration enValue = ht.elements();
while(enValue.hasMoreElements()) {
String sValue = (String) enValue.nextElement();
System.out.println("enValue = " + sValue);
}
Enumeration enKey = ht.keys();
while(enKey.hasMoreElements()) {
String sKey = (String) enKey.nextElement();
System.out.println("enKey = " + sKey);
}
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.84.27.29
推
01/30 16:56, , 1F
01/30 16:56, 1F
→
01/30 17:40, , 2F
01/30 17:40, 2F
→
01/30 17:43, , 3F
01/30 17:43, 3F
※ 編輯: rg550 來自: 219.84.27.29 (01/30 17:54)
推
01/30 19:18, , 4F
01/30 19:18, 4F
→
01/31 12:56, , 5F
01/31 12:56, 5F