java中Hashtable的使用案例及与HashMap的区别
来源:互联网 发布:管家婆数据库在哪里 编辑:程序博客网 时间:2024/06/06 01:28
package itcast07;import java.util.HashMap;import java.util.Hashtable;/** * 1. Hashtable 和HashMap的区别 * Hashtable: 线程安全,效率低。不允许使用null键和null值。 * HashMap: 线程不安全,效率高。允许使用null键和null值。 * * 2. List, Set, Map等接口是否都继承自Map接口? * List, Set不是继承自Map接口,它们继承自Collection接口 * Map接口本身就是一个顶层接口 * * @author lgt * */public class HashtableDemo { public static void main(String[] args) { // 创建HashMap集合 HashMap<String, String> hm = new HashMap<String, String>(); // 添加元素 hm.put("hello", "world"); hm.put(null, null); // 输出集合 System.out.println(hm); // 创建Hashtable集合 Hashtable<String, String> ht = new Hashtable<String, String>(); // 添加元素 ht.put("java", "eclipse"); ht.put("2017", "0420"); // 出现错误 // ht.put(null, null); // 输出集合 System.out.println(ht); }}
0 0
- java中Hashtable的使用案例及与HashMap的区别
- java中Hashtable与HashMap的区别
- Java中HashTable与HashMap的区别
- java中HashMap与Hashtable的区别
- Java中HashMap与Hashtable的区别
- java中hashmap与hashtable的区别
- Java中HashMap与HashTable的区别
- Java中Map接口HashMap与HashTable的区别及HashMap深入理解
- Java中Map接口HashMap与HashTable的区别及HashMap深入理解
- Java中HashTable、HashMap、WeakHashMap的区别及用法小结
- 【java】Java中Map与HashMap,Hashtable,HashSet的区别
- Java中Map与HashMap,Hashtable,HashSet的区别
- Java中Map与HashMap,Hashtable,HashSet的区别
- Java中Map与HashMap,Hashtable,HashSet的区别
- java 中 HashMap 与HashTable之间的区别
- 浅析Java中Map与HashMap,Hashtable,HashSet的区别
- 浅析Java中Map与HashMap,Hashtable,HashSet的区别
- 浅析Java中Map与HashMap,Hashtable,HashSet的区别
- Lua之coroutine基础
- Python学习笔记 --- 解析 type 和 object
- iOS点击短信中的链接跳转到App
- js进阶01.面向对象编程之女票的生产方法
- Windows安装rabbitmq
- java中Hashtable的使用案例及与HashMap的区别
- Climbing Stairs
- Redis 监控(Redis Monitoring)
- JDK自带工具keytool生成ssl证书
- Linux上安装JDK、Tomcat
- git将文件夹(整个项目)上传到github
- 从零开始学JAVA:java 静态导入 (import static) 详解
- 堆排序
- Hessian 原理分析、代码示例