Java中HashMap和Map的区别..? [重复]

时间:2021-09-28 16:43:53

Possible Duplicate:
Java - HashMap vs Map objects

可能重复:Java - HashMap与Map对象

I want to know the difference between HashMap and Map in java..??

我想知道Java中HashMap和Map的区别.. ??

5 个解决方案

#1


46  

Map is an interface, i.e. an abstract "thing" that defines how something can be used. HashMap is an implementation of that interface.

Map是一个接口,即一个定义如何使用某事物的抽象“事物”。 HashMap是该接口的实现。

#2


17  

Map<K,V> is an interface, HashMap<K,V> is a class that implements Map.

Map 是一个接口,HashMap 是一个实现Map的类。 ,v> ,v>

you can do

你可以做

Map<Key,Value> map = new HashMap<Key,Value>();

Here you have a link to the documentation of each one: Map, HashMap.

在这里,您可以找到每个文档的链接:Map,HashMap。

#3


3  

Map is an interface; HashMap is a particular implementation of that interface.

地图是一个界面; HashMap是该接口的特定实现。

HashMap uses a collection of hashed key values to do its lookup. TreeMap will use a red-black tree as its underlying data store.

HashMap使用散列键值的集合来进行查找。 TreeMap将使用红黑树作为其底层数据存储。

#4


2  

Map is an interface in Java. And HashMap is an implementation of that interface (i.e. provides all of the methods specified in the interface).

Map是Java中的一个接口。 HashMap是该接口的实现(即提供接口中指定的所有方法)。

#5


1  

HashMap is an implementation of Map. Map is just an interface for any type of map.

HashMap是Map的一个实现。 Map只是任何类型地图的界面。

#1


46  

Map is an interface, i.e. an abstract "thing" that defines how something can be used. HashMap is an implementation of that interface.

Map是一个接口,即一个定义如何使用某事物的抽象“事物”。 HashMap是该接口的实现。

#2


17  

Map<K,V> is an interface, HashMap<K,V> is a class that implements Map.

Map 是一个接口,HashMap 是一个实现Map的类。 ,v> ,v>

you can do

你可以做

Map<Key,Value> map = new HashMap<Key,Value>();

Here you have a link to the documentation of each one: Map, HashMap.

在这里,您可以找到每个文档的链接:Map,HashMap。

#3


3  

Map is an interface; HashMap is a particular implementation of that interface.

地图是一个界面; HashMap是该接口的特定实现。

HashMap uses a collection of hashed key values to do its lookup. TreeMap will use a red-black tree as its underlying data store.

HashMap使用散列键值的集合来进行查找。 TreeMap将使用红黑树作为其底层数据存储。

#4


2  

Map is an interface in Java. And HashMap is an implementation of that interface (i.e. provides all of the methods specified in the interface).

Map是Java中的一个接口。 HashMap是该接口的实现(即提供接口中指定的所有方法)。

#5


1  

HashMap is an implementation of Map. Map is just an interface for any type of map.

HashMap是Map的一个实现。 Map只是任何类型地图的界面。