Java实用工具类详解
1. Hashtable迭代器的使用
在处理 Hashtable 时,我们可以使用 entrySet() 或 keySet() 方法获取键的集合视图。例如,我们可以获取键的集合视图,并使用迭代器或增强 for 循环遍历它们。以下是一个展示该技术的示例代码:
// Use iterators with a Hashtable.
import java.util.*;
class HTDemo2 {
public static void main(String args[]) {
Hashtable<String, Double> balance =
new Hashtable<String, Double>();
String str;
double bal;
balance.put("John Doe", 3434.34);
balance.put("Tom Smith", 123.22);
balance.put("Jane Baker", 1378.00);
balance.put("Tod Hall", 99.22);
balance.put("Ralph Smith", -19.08);
// Show all balances in hashtable.
// First, get a set view of the keys.
Set<String&
超级会员免费看
订阅专栏 解锁全文
390

被折叠的 条评论
为什么被折叠?



