I'm making an array with lists of nodes that I have to organize from another list that contains 200 nodes with a value from 0 to 9 each (value assigned random).
The Nodes must be removed from the Main List and assigned to the corresponding List within the array according to their value.
For example, if when deleting a Node that has an 8 inside, I must assign it to the List in position 8 within the array. That while is to erase and assign the nodes but throws me NullPointerException when calling the addEnd method.
This is the code where I get the error:
while(n > 0){
Nodo x = myList.deletStart();
for(int a = 0; a < 10; a++){
if(a == x.getInfo()){
arr[a].addEnd(x);
//arr[a].addEnd(new Nodo(x.getInfo()));
break;
}
}
myList.mostrar();
System.out.println();
n--;
}
I initialize the List in this way:
static Lista[] arr = new Lista[10];