mardi 3 novembre 2015

Java Array If Empty multiple classes

I am kinda stuck on this one.

//DataBase class    

public int getStorageSize() 
{ 
    myStorageSize=5;
    return myStorageSize;
}

BookIds[] is empty by default.

public boolean isRowEmpty(int libPos)
{
    if(bookIds[libPos] == 0)
        {
            return true;
        }
    else
        {
            return false;
        }
}

And here comes the code from main class

for(int i=0;i<myDB.getStorageSize();++i) 
                                    if(myDB.isRowEmpty(i)==true)
                                        {
                                            id=i;
                                            break;
                                        }

So I was expecting id to be equal 1. but it gives 0. What did am I missing?

Aucun commentaire:

Enregistrer un commentaire