最佳答案
Possible Duplicate:
Storing primitive values in a Java collection?
In java when I use the following :-
public HashMap<char, int> buildMap(String letters)
{
HashMap<char, int> checkSum = new HashMap<char, int>();
for ( int i = 0; i < letters.length(); ++i )
{
checkSum.put(letters.charAt(i), primes[i]);
}
return checkSum;
}
I get errors related to inappropriate types. I solved my problem by using Character and Integer instead of char and int respectively. However, I'm having trouble figuring out why HashMap fails to be able to deal with primitive data types.