Cumulative Project 4, Cannot return an Object of an ArrayList I created. I get a "cannot find symbol" error

I keep getting this error at step 11: error: cannot find symbol
return questions.get(currentQuestionIndex);
symbol: variable questions
location: class MainActivity
1 error

My code:

import java.util.ArrayList;

public class MainActivity {

// TODO #1: add integer member variables here
int currentQuestionIndex;
int totalCorrect;
int totalQuestions;  
// TODO #2: add ArrayList member variable here
ArrayList<Question> questionStuff = new ArrayList<Question>();
// TODO #3 add startNewGame() here    
public void startNewGame(){
  totalCorrect = 0;
  totalQuestions = 0;
  Question q1 = new Question(921238,
  "How tall is the Eiffel tower?",
  "1024 ft",
  "1063 ft",
  "1124 ft",
  "1163 ft", 1);

  Question q2 = new Question(107343,
  "Who invented the computer algorithm?",
  "Charles Babbage",
  "John Carmack",
  "Alan Turing",
  "Ada Lovelace",

  Question q3 = new Question(748294,
  "What is the name for the patch of skin found on your elbow?",
  "Elbow Skin",
  "Fascia Elbora",

  ArrayList<Question> questions = new ArrayList<Question>();

  Question firstQuestion = chooseNewQuestion();
  // displayQuestion(firstQuestion);
  // displayQuestionsRemaining(questions.saze());

// TODO #4 add chooseNewQuestion() here
  public Question chooseNewQuestion(){
    int randomQuestion = generateRandomNumber(2);
    currentQuestionIndex = randomQuestion;
    return questions.get(currentQuestionIndex);
// TODO #5 add getCurrentQuestion() here

// TODO #6 add onAnswerSubmission() here

int generateRandomNumber(int max) {
  double randomNumber = Math.random();
  double result = max * randomNumber;
  return (int) result;

String getGameOverMessage(int totalCorrect, int totalQuestions) {
    if (totalCorrect == totalQuestions) {
        return "You got all " + totalQuestions + " right! You won!";
    } else {
        return "You got " + totalCorrect + " right out of " + totalQuestions + ". Better luck next time!";


I am unsure of what has been causing it but ive been stuck on it for 2 days now. Any help would be appreciated.

I could be very wrong about this, but …

I don’t see the variable questions declared in the class, only in the startNewGame() method.
I don’t know if the questions variable would have the correct scope to be used by other methods.
(I see questionStuff at the top, defined for the class.)

Also in
// displayQuestionsRemaining(questions.saze());
questions.saze() should be questions.size()
but that doesn’t actually matter because its a comment.

Okay I am starting to visualise my lack of knowledge in variable scopes AND ArrayLists. lol. So, how would I put the “questions” array in scope so that my chooseNewQuestion() method can see it and use it?

The earlier steps of the lesson told me to create a new ArrayList of objects outside of the startNewGame() but inside the MainActivity class. I named it “questionStuff” above but changed the name to “questions” after I read your comment and I believe the compiler liked that but I had to comment-out the Arraylist “questions” in startNewGame(). Now, if my understanding is correct, I need to fix my ArrayList now in startNewGame(). The lesson told me to create the ArrayList and assign it to the “questions” ArrayList I created that is outside of the startNewGame(). I tried several ways to do that but the compiler is still giving me errors. How would I assign the ArrayList within a method to the questions arraylist(formerly the questionStuff in the code above)?

Edit: WAIT. So I think it worked. Your comment just clicked with me and I no longer receive the errors. I renamed the ArrayList to questionsArray in startNewGame() and the next line after the 3 .add() calls, I put “questions = questionsArray” and I stopped getting the errors.

What WASNT working was when I did this:
questions = ArrayList questionsArray = new ArrayList();
which sort of makes sence to me why it wouldnt work.

Thank you very much!