[Solved] My code is throwing a NullPointerException in Java [duplicate]


for(int i = 1; i <= currentSize; i++)
  list[i] = valuesHolder[i];

This part is the culprit. You have to copy contents of ‘list’ to newly created array ‘valuesHolder’. Instead you are doing the other way, which results in ‘null’ entries. The change you have to make is this:

for(int i = 1; i <= currentSize; i++)
  valuesHolder[i] = list[i];

1

solved My code is throwing a NullPointerException in Java [duplicate]