在java中创建多维ArrayList

Nic*_*son 0 java

我想创建一个arrayList如下.

id->1512   associated with the values -> 12,45,78
id->1578   associated with the values -> 456,78,87,96
Run Code Online (Sandbox Code Playgroud)

我该怎么办?我应该创建一个二维数组列表,还是可以用单维arraylist创建?

Per*_*ror 5

你正在寻找这样的东西:

Map<Integer, List<Integer>>
Run Code Online (Sandbox Code Playgroud)