0

I have an Array of Room objects from the Room class that has a toString method. I want to take the Room[] and convert it to String[] using the toString method of each room object in the list. I get a null pointer exception when running. Here a snip of my code (the method eclipse states is throwing the error).

public String[] getDescriptions() {

    String[] descriptionList = new String[5];
    int boardNumber = 0;
    for (Room current : this.board) {
        descriptionList[boardNumber] = current.toString();
        boardNumber++;
    }
    return descriptionList;
}

Thank you in advance.

0 Answers0