I can't figure out what the error is.

public void quizTest ()
    {
        c = new Console();
        int total = 34;
        String[] quizArray = new String [total];
        String quizQuestions;
        int i = 0;
        int u = 0;

        try
        {
            FileReader readQuestion = new FileReader ("QuizQuestions1.txt");
            BufferedReader buffReadQuestion = new BufferedReader (readQuestion);

            while ((quizQuestions = buffReadQuestion.readLine ()) != null)
            {
                quizArray [u] = quizQuestions;
                u++;
            }


            for (i = 0 ; i > u ; i++)
            {
                c.println (quizArray [i]);
            }
        }
        catch (IOException e)
        {
            new Message ("Error");
        }

    }

Here's the error message:

java.lang.ArrayIndexOutOfBoundsException: 34
at BooleanLogic.quizTest(BooleanLogic.java:342)
at BooleanLogic.main(BooleanLogic.java:367)

for (i = 0 ; i > u ; i++)
            {
                c.println (quizArray [i]);
            }

should be changed to

for (i = 0 ; i < quizArray.length ; i++)
            {
                c.println (quizArray [i]);
            }

Actually checking quizArray.length will make sure that you do not get that exception, and, when you change the amount of quiz questions (the total variable), you won't have to change anything else.

Oh thanks. That fixed it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.