Java: 声明HashMap 时的方括号?

Java: square brackets when declaring HashMap?

我正在尝试改编来自 here 的代码,但我不明白为什么他们使用方括号声明和实例化了他们的 HashMap。这是一些简化的示例代码:

class CommunityStructure {
    HashMap<Modularity.Community, Float>[] nodeConnectionsWeight;
    HashMap<Modularity.Community, Integer>[] nodeConnectionsCount;
    int N;
    ...

    CommunityStructure(Graph graph) {
    ...
    N = graph.getNodeCount();
    nodeConnectionsWeight = new HashMap[N];
    }
    ...
}

我以为方括号主要用于数组,所以看到它们也适用于地图时我感到很困惑。

"They" 正在声明 HashMap 的数组。

这是完全合法的。

每个数组将包含多个 HashMap<Modularity.Community, Float> 实例(或 Integer 作为第二个变量中的映射值)。