K
K
koi com2015-03-30 22:48:57
Java
koi com, 2015-03-30 22:48:57

How to correctly generate keys for HashMap and what type?

Is there any generally accepted way to generate keys and what should they be? While generating integer keys, the next key is an increment of the previous one. I look forward to links to resources, reasonable answers.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2015-03-31
@koi_jp

The key in a HashMap can be anything (even NULL ) The HashMap uses the result of the Object.hashCode() method as a key . On this occasion, Bloch is very well written, read

V
Vladimir Abramov, 2015-03-31
@kivsiak

There is no generally accepted. Describe the task.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question