Can I have this kind of a structure in a linked list?
public class myLinkedList{
myLinkedList parent;
String data;
myLinkedList[] next;
}
The problem is, this node might or might not have multiple connections.
Thanks!
The language allows your class to hold your reference next to the mylinkedlist array.
However, a linked list is linear. Your structure may be a tree or a graph.
nextarray can have multiple values, including none. Is the question just that?next = new myLinkedList[99]; next = new myLinkedList[1]; next = new myLinkedList[30];. Keep in mind we are assigning a brand new array here everytime, not expanding its size. If you need dynamic size, you should go for a Collection likeArrayList.