Anand Kumar Anand Kumar - 1 year ago 103
Java Question

Linked List of Linked Lists in Java

I would like to know how to create a linked list of linked lists. Also, It would be helpful if the predefined

(class from Java) and its methods are used for defining and for other add, get, listIterating operations.

Answer Source

You can put any object in a list.

LinkedList<LinkedList<YourClass>> list = new LinkedList<LinkedList<YourClass>>();

is a LinkedList of LinkedLists of YourClass objects.

If you want to add specific methods to this list, you can create a subclass of LinkedList or you can create a class with the list of lists as a field and add there methods to manipulate the list.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download