Listing 2.7 cannot resolve crash


The issue is listing 2.7 with this code:

int question = questionBank[currentIndex].getTextResId() ;

it crashes and I can not figure out why. Can anyone help?

here is the

public class Question {

private int textResId;
private boolean answerTrue;
public Question( int textResId, boolean answerTrue){
    this.textResId = textResId;
    this.answerTrue = answerTrue;
public int getTextResId() {
    return textResId;
public void setTextResId(int textResId) {
    this.textResId = textResId;
public boolean isAnswerTrue() {
    return answerTrue;
public void setAnswerTrue(boolean answerTrue) {
    this.answerTrue = answerTrue;




Resolved, don’t know why but it is working.


Hi Grady,
How it works for you ?
I am new to Android and stuck at this point, whenever I run my app it crashes.
I turned this piece of code into this as well
mQuestionTextView.setText(Integer.toString(question)); but it show me 0 instead of question text.
Any solution ?