package learnExample;
import java.util.Hashtable;
public class Learn {
public static void main(String args[])
{
Hashtable<String,Integer> Learn = new Hashtable<String, Integer>(); //String为key,int为value
Learn.put("one", 1);
Learn.put("two", 2);
Learn.put("three",3);
Integer n = Learn.get("two");
if(n!=null)
System.out.println("two="+n);
}
}
本文通过一个简单的 Java 示例介绍了如何使用 Hashtable 类来存储和检索键值对数据。示例中使用 String 作为键,Integer 作为值,并展示了 put 和 get 方法的基本用法。
1594

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



