我有以下类型的哈希图:

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 []数组?

我得到强制转换的错误,得到likesYearHashMap.values();

最佳答案

像这样:

map.values().toArray(new HashMapObject[map.size()])

10-08 06:59