Need help with equalityoperators

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

https://www.codecademy.com/courses/learn-java/lessons/introduction-to-java/exercises/equality-operators.

```

public class EqualityOperators {
public static void main(String args) {

char myChar = '4';

int myInt = -2;

	System.out.println(myChar == myInt);

}

}

<do not remove the three backticks above>

You have an odd number of curly braces.

Sorry. Ignore that my screen was truncated.

I am not sure what this exercise is asking of me.

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

Let us break down what these instructions are saying. “Use any equality operator” What are our equality operators? == (equal to) or != (not equal to). “to directly compare” so we are going to have an inequality of some type set up here. “compare two Boolean values” so what are our Boolean values? true and false. “Do not declare any variables” this is important because we are directly comparing the Booleans to each other. And in your code you have variables so while what you have done is correct it is not what the lesson is looking for. We also want this printed out so we will put our inequality in the System.out.println();.

So all in all your final code should look something like this:

System.out.println(true == false);
1 Like

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