vendredi 30 octobre 2015

Incompatible types: Card cannot be converted to java.lang.String

I keep getting this error with my code. I can't seem to find the problem.

I'm not sure what to do because I even looked in the text book and it gives me a similar method except with different variables.

I'm on BlueJ.

 public int findFirstOfPlayer(String searchString)
{
    int index = 0;
    boolean searching = true;
    while(index < cards.size() && searching) {
        String cardname = cards.get(index); // Error highlights index
        if(cardname.contains(searchString)) {
            searching = false;
        }
        else {
            index++;
        }
        if(searching) {
            return -1;
        }
        else {
            return index;
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire