When compiling code I get the bad operand error

Every time I try to compile my code I get a 'bad operand' error involving boolean and int arrays. Any help would be appreciated. Thank you!

System.out.println("Passed: " + passed); 

if (exam.totalIncorrect() > 0)
{
    System.out.println("The incorrect answers are: "); 

    int missedIndex; 

    for (int i = 0; i < exam.totalIncorrect(); i++)
    {
        missedIndex = exam.questionsMissed()[i]+1; 
        System.out.print(" " + missedIndex); 
    }
}

The error I get is this:

   DriverExamApplication.java:58: error: bad operand types for binary operator   
   '+'   
            missedIndex = exam.questionsMissed() [i] +1; 

                                         ^

first type:  boolean

second type: int

Answers


You are trying to add a boolean with an integer....

Print it directly and save time converting types

System.out.print(" " + exam.questionsMissed()[i]+i+1);

Looks like exam.questionsMissed() returns an array of boolean. Then exam.questionsMissed()[i] is boolean, and you are trying append 1 to it.


Need Your Help

Entity Framework MigrationSqlGenerator for SQLite

c# .net entity-framework sqlite migration

is there a MigrationSqlGenerator for SQLite to use with entity framework? I only found one from devart which is commercial.

Django: Saving an image file from a form

python django django-forms django-views

I want to save the image which as been uploaded via the PaletteGenForm as such: