VincentLamoute
VincentLamoute

Reputation: 810

"The operator == is undefined for the argument type(s) boolean, null"

Why eclipse say :

"The operator == is undefined for the argument type(s) boolean, null"

At the if statement ? Why is inauthorized to write it ?

Object max;
double a1;
double a2;

if ((max != null && a1 > a2) ¦¦ max == null)
     // Something

Upvotes: 1

Views: 13341

Answers (2)

Suresh Atta
Suresh Atta

Reputation: 121998

Just tested, Everything fine, other than that mysterious ¦¦ ,use ||

Object max = null;
        double a1 = 0;
        double a2 = 0;

        if ((max != null && a1 > a2) || max == null){

        }

Eclipse just confused and saying

The operator == is undefined for the argument type(s) boolean, null


if ( (max != null && a1 > a2)  ¦¦ max == null  ){
     ........^........(boolean) , ..null....... (treating that ¦¦ as comma)
        }

Upvotes: 4

Ioan
Ioan

Reputation: 5187

In order to make your code to compile, you just have to initialize the variables before, and get rid of this ¦¦ - I think you wanted to use OR which is ||

Object max = null;
double a1 = 0;
double a2 = 0;

if ((max != null && a1 > a2) || max == null){}

Upvotes: 3

Related Questions