im trying to sort through an array and i keep getting a null pointer exception when i do... can anyone see where im going wrong....thanks
getreleasedate() gets the gregorian calendar date for each object in array.
new CD() creates an empty array that can hold five objects
public void sortByNewest()
{
if(counter > 1)
{
CD extra = new CD();
for(int outer = 0; outer < counter - 1; outer++)
{
for(int inner = 0; inner < counter - 1; inner++)
{
if( myCDs[inner].getreleaseDate().after(myCDs[inner + 1].getreleaseDate()))
{
//this part i got help from robert
extra = myCDs[inner] ;
myCDs[inner] = myCDs[inner + 1];
myCDs[inner + 1] = extra;
}
}
}
}
}