Hello. I am in need of assistance for sorting an array of objects. I have two variables called "BallInfo infos" which holds the objects inside an array of BallInfo, and a another variable called "numOfInfos" that keeps track of the actual amount of objects inside the array:
So I am unsure why I am getting a NullPointerException for the following code below:
infos = new BallInfo[43];
numOfInfos = 0;public void sortByTotal()
{
boolean notSorted = true;
while (notSorted)
{
notSorted = false;
for (int index=0; index<numOfInfos; index++)
{
if (infos[index].getTotal() < infos[index+1].getTotal()) //I get the error on this line of code
{
swap(index, index+1);
notSorted = true;
}
}
}
}
