0

I have been trying to create an output for an array list of API books using JSON object and this array code gives a hint not a statement. Below is the block of code in Java using Android Studio

Book book = new Book {
  bookJSON.getString(ID),
    volumeInfoJSON.getString(TITLE),
    (volumeInfoJSON.isNull(SUBTITLE)?"":volumeInfoJSON.getString(SUBTITLE)),
    authors, volumeInfoJSON.getString(PUBLISHER), 
    volumeInfoJSON.getString(PUBLISHED_DATE);

    books.add(book);
  }
}

1 Answer 1

3

Maybe you should change it like this?

Book book = new Book {
    bookJSON.getString(ID),
    volumeInfoJSON.getString(TITLE),
    (volumeInfoJSON.isNull(SUBTITLE)?"":volumeInfoJSON.getString(SUBTITLE)),
    authors, volumeInfoJSON.getString(PUBLISHER), 
    volumeInfoJSON.getString(PUBLISHED_DATE);
}
books.add(book);

The only difference is I put the books.add(book) statement out of new Book {} block.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.