Java Equivalent to Python Dictionaries

后端 未结 4 1042
野的像风
野的像风 2020-11-27 16:03

I am a long time user of Python and really like the way that the dictionaries are used. They are very intuitive and easy to use. Is there a good Java equivalent to python\'s

4条回答
  •  执念已碎
    2020-11-27 16:17

    Python's dict class is an implementation of what the Python documentation informally calls "mapping types". Internally, dict is implemented using a hashtable.

    Java's HashMap class is an implementation of the Map interface. Internally, HashMap is implemented using a hashtable.

    There are a few minor differences in syntax, and I believe the implementations are tuned slightly differently, but overall they are completely interchangeable.

提交回复
热议问题