我的 HashMap 类型为:
private HashMap<String, HashMapObject> likesYearHashMap;
其中 HashMapObject :
public class HashMapObject {
private int count;
private String id;
public HashMapObject(int count, String id) {
super();
this.count = count;
this.id = id;
}
}
如何将我的 HashMap 中的值转换为 HashMapObject[] 数组?
我在 Actor 获取 likesYearHashMap.values(); 时遇到错误
最佳答案
像这样:
map.values().toArray(new HashMapObject[map.size()])
关于java - 如何将HashMap转换为自己类型的数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21094973/