`ArrayList elements as Map key?
T
T
Truefiber2013-06-18 08:37:43
Java
Truefiber, 2013-06-18 08:37:43

ArrayList elements as Map key?

There is an ArrayList < `Character > list, there is a HashMap<Character, Integer> map
Why does the compiler in map.put(list[i], 0) swear at list[i] in the loop? At the same time, if you convert to an array char[ ] arrayChar = list.toArray(), then map.put(arrayChar[i], 0) does not cause problems.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
senneco, 2013-06-18
@senneco

Looks like you need to write map.put(list.get(i), 0)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question