Need help with equalityoperators


public class EqualityOperators {
	public static void main(String[] args) {
    char myChar = '4';
    int myInt = -2;
		System.out.println(myChar == myInt);



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.


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);


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