如何将值从二维数组复制到双向链表

How to copy values from 2d array to doubly linked list

如何从二维数组中取值到双向链表?我知道如何使用 ArrayList 来实现它,但我不知道如何使用双向链表来实现它。我如何将二维数组中的所有内容复制到 LinkedList?我需要 LinkedLists 的 LinkedList 吗?

如果我有

int[][] myArray = {{1,2,3}
                              {4,5,6},
                              {7,8,9}};

那么 LinkedList 应该看起来完全一样,即:

[[1,2,3]
 [4,5,6],
 [7,8,9];

public void copyFromArray(int[][] myArray){

}

public class Node<Integer> {

    public Integer data;

    public Node<Integer> prev, next;

    public Node( Integer d, Node<Integer> p, Node<Integer> n ){
         this.data = d;
         this.prev = new Node();
         this.next = new Node();
    }

  }

是的,你需要一个链表的链表:

LinkedList<LinkedList<Integer>> list = new LinkedList<>();
int[][] myArray = { {1, 2, 3}, {4,5,6},{7,8,9} };
for (int i = 0; myArray.length >= i; i++) {
        LinkedList<Integer> auxList = new LinkedList<>();
          for (int j = 0; myArray[i].length >= j; j++) {
            auxList.add(myArray[i][j]);
        }
        list.add(auxList);            
 }