Why Java compiler does not like integer as type for values in HashMap?
- by Roman
The compiler complains about this code:
HashMap<String,int> userName2ind = new HashMap<String,int>();
for (int i=0; i<=players.length; i++) {
userName2ind.put(orderedUserNames[i],i+1);
}
It writes "unexpected type" and point on int. If I replace int by String and i+1 by i+"1", the compilation goes OK. What is wrong with in here?