请考虑以下代码:
import java.util.*;
class Employee {
String name;
public Employee(String nm) {
this.name=nm;
}
}
public class HashMapKeyNullValue {
Employee e1;
public void display(){
Employee e2=null;
Map map=new HashMap();
map.put(e2, "25");
System.out.println("Getting the Value When e2 is set as KEY");
System.out.println("e2 : "+map.get(e2));
System.out.println("e1 : "+map.get(e1));
System.out.println("null : "+map.get(null));
map.put(e1, "");
System.out.println("Getting the Value when e1 is set as KEY");
System.out.println("e2 : "+map.get(e2));
System.out.println("e1 : "+map.get(e1));
System.out.println("null : "+map.get(null));
map.put(null, null); // null as key and null as value
System.out.println("Getting …
Run Code Online (Sandbox Code Playgroud) 我知道这个问题可能有点愚蠢,但我只是想澄清疑问.在浏览Collection的Java教程(http://docs.oracle.com/javase/tutorial/collections/index.html)时,我没有找到有关Vector和Hashtable的任何相关信息.两者都属于Collection框架,因为Vector是List的实现,而Hashtable是Map的实现.如果是这样那么为什么它不在Sun教程中?我在哪里可以找到Sun的Collection教程,其中包含有关Vector和Hashtable的优秀文档以及有关存储在List,Set和Map中的元素的深入知识?