NullPointerException when Creating an Array of objects

Problem Statement: I have been trying to create an array of a class containing two values but when I try to apply a value to the array I get a NullPointerException.

public class ResultList {    public String name;    public Object value;public ResultList() {} } public class Test {    public static void main(String[] args){        ResultList[] boll = new ResultList[5];        boll[0].name = "iiii";    }}Why am I getting this error and how can I fix it?

Solution:

ResultList[] boll = new ResultList[5];

creates an array of size=5, but does not create the array elements.

You have to instantiate each element.

for(int i=0; i< boll.length;i++)    boll[i] = new ResultList();