小编Niz*_*zam的帖子

具有空键和空值的HashMap

请考虑以下代码:

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)

java collections null hashmap hashcode

16
推荐指数
2
解决办法
6万
查看次数

我在哪里可以找到Java中的文档Vector和Hashtable?

我知道这个问题可能有点愚蠢,但我只是想澄清疑问.在浏览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中的元素的深入知识?

java collections hashtable vector

0
推荐指数
1
解决办法
455
查看次数

标签 统计

collections ×2

java ×2

hashcode ×1

hashmap ×1

hashtable ×1

null ×1

vector ×1