哈希表
//hashTable和hasMap的异同
//map接口的实现类有hashtable, hashMap
//hashtable是map接口的实现类,线程安全,效率低,不能存储null的key,value
//hashmap是map接口的实现类,线程不安全,效率高,可以存储null的Key,value
//hashmap 有一个子类,linkedHashMap是hashMap的子类
package com.shizhong.hashtable;
import java.util.Scanner;
public class HashTableDemo {
public static void main(String[] args) {
HashTable hashTable = new HashTable(7);
String key = " ";
Scanner scanner = new Scanner(System.in);
while (true) {
System.out.println("add: 添加雇员");
System.out.println("list: 显示雇员");
System.out.println("find: 查找雇员");
System.out.println("exit: 退出系统");
key = scanner.next();
switch (key) {
case "add":
System.out.println("输入id");
int id = scanner.nextInt();
System.out.println("输入名字");
String name = scanner.next();
Emp emp = new Emp(id, name);
hashTable.add(emp);
break;
case "list":
hashTable.list();
break;
case "find":
System.out.println("输入id");
id = scanner.nextInt();
hashTable.findEmpById(id);
break;
case "exit":