Anand Kumar Anand Kumar - 7 months ago 63
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.


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.