Equality Operators


Equality operators do not require that operands share the same ordering. For example, you can test equality across boolean, char, or int data types. The example below combines assigning variables and using an equality operator:

char myChar = ‘A’;
int myInt = -2;
System.out.println(myChar == myInt);

The example above will print out false because the value of myChar (‘A’) is not the same value as myInt (’-2’).

  1. Use any equality operator to directly compare two Boolean values. Do not declare any variables.

I’m not sure what to do. How do I compare two boolean values without using any variables?


just like you can use strings and integers:

'A' == -2

directly in the comparison, you can also use Boolean values without saving them to variable first


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.