Java: How to create an array of Map<String,Object> objects [duplicate]
Possible Duplicate:
Cannot create an array of LinkedLists in Java…?
I want to call this method:
executeBatch(Map<String,Object>[] batch)
But for the life of me I can't figure out how to create an array of Map<String,Object>[]
I get the error "Can create a generic 开发者_开发技巧array of HashMap" when I try HashMap<String,Object>[] params = new HashMap<String,Object>[20000];
I also failed at attempting to cast an ArrayList.toArray()
to a HashMap<String,Object>[]
You really cant. You have to do it like this:
@SuppressWarnings("unchecked")
HashMap<String, Object>[] map = new HashMap[20000];
Or with a more barbaric solution you can compile adding:
-Xlint:unchecked
精彩评论