请教关于Hashtable的使用!

attiseve 2003-06-09 09:05:08
Hashtable怎么用?用不用try{...}catch{...},抛出什么类?怎么按照j2sdk_doc中介绍的Hashtable的使用方法也不行?
...全文
86 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangjuanli 2003-06-09
  • 打赏
  • 举报
回复
gdsean(摇滚java) 写的基本正确,
只是非曲直 System.out.println("two = " n);
应写成 System.out.println("two = " + n);
gdsean 2003-06-09
  • 打赏
  • 举报
回复
This example creates a hashtable of numbers. It uses the names of the numbers as keys:


Hashtable numbers = new Hashtable();
numbers.put("one", new Integer(1));
numbers.put("two", new Integer(2));
numbers.put("three", new Integer(3));

To retrieve a number, use the following code:


Integer n = (Integer)numbers.get("two");
if (n != null) {
System.out.println("two = " n);
}

attiseve 2003-06-09
  • 打赏
  • 举报
回复
谢谢关注!
javastu 2003-06-09
  • 打赏
  • 举报
回复
关注!

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧