Getting NullReferenceException despite assigning an object

I don’t understand why am I getting the NullReferenceException error although I have already assigned a gameobject.

public class PositionSavers : MonoBehaviour
{
    public GameObject tracked;
    private static int n = 0;
    private static Vector3[] objectPositions = null;

    private void Start()
    {
    }

    private void Update()
    {
        if(n < 500)
        {
            objectPositions[n] = tracked.transform.position;
            n++;
        }
        if(n == 500)
        {
            Save(objectPositions);
            n++;
        }
    }
}

3474832--276151--upload_2018-4-26_5-45-30.png

3474832--276153--upload_2018-4-26_5-46-41.png

You get null from there? objectPositions[n] = tracked.transform.position;
Probably yes, your array is null private static Vector3[ ] objectPositions = null;. I don’t see anywhere in code where you initialize it, so it’d be still null.

Thanks for replying!! I just solved the problem. I am a new learner to this. So sorry for the stupid question.