Initialization Required for Array of Objects to Avoid NullPointerException
In your code, you have declared an array of objects, but you haven't initialized them. When you create an array, the elements are not automatically initialized with new instances of the class. Instead, they initially hold null values.
ResultList[] boll = new ResultList[5];
Consequently, when you attempt to access an element of the array, such as boll[0], you encounter a NullPointerException because boll[0] is initially null.
To resolve this issue and avoid the exception, you need to initialize the array elements with new instances of the ResultList class. This can be done by adding the following line before accessing the element:
boll[0] = new ResultList();
This line creates a new instance of the ResultList class and assigns it to the first element of the array. Now, you can access and modify the properties of boll[0] without encountering a NullPointerException.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3