在java中向iterable列表添加集合

在java中向iterable列表添加集合,java,set,iterable,Java,Set,Iterable,所以我有一些集合,我想把元素添加到LinkedList中,这样我就可以对它们进行迭代。我将如何在java中执行此操作?摘自此处的一个问题: 用密码。用密码。或者进行互联网搜索,然后进行编码。puslic static void main(字符串[]args) class Node { Object data; Node next; Node(Object d,Node n) { data = d ; next = n ; }

所以我有一些集合,我想把元素添加到LinkedList中,这样我就可以对它们进行迭代。我将如何在java中执行此操作?

摘自此处的一个问题:


用密码。用密码。或者进行互联网搜索,然后进行编码。
puslic static void main(字符串[]args)
class Node {
    Object data;
    Node next;
    Node(Object d,Node n) {
        data = d ;
        next = n ;
       }

   public static Node addLast(Node header, Object x) {
       // save the reference to the header so we can return it.
       Node ret = header;
   // check base case, header is null.
   if (header == null) {
       return new Node(x, null);
   }

   // loop until we find the end of the list
   while ((header.next != null)) {
       header = header.next;
   }

   // set the new node to the Object x, next will be null.
   header.next = new Node(x, null);
   return ret;
   }
}