11/12 Equality Operators


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

My code:
public class EqualityOperators {
public static void main(String[] args) {

int myInt = 1;

int myInt = 1;
System.out.println(myInt == myInt);



I don't know where is the problem?
Please help


It seems like you should really just do what is asked in the instructions:

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


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

would already be suffiecient.


Thanks for the posting the answer. I got confused with the "Do not declare any variables" part of the question. I thought how can I compare 2 values but not state what those 2 values were.

The key words in the instructions is "compare two boolean values" ie the values HAVE to be boolean!


They can't have the same name though, unless you get WAY into specifics of programming, I'd say always use a different name for everything.

so you should never compare "myInt" to "myInt" it should compare to something else, because right now it's just comparing it against itself. which doesn't make sense.


hola pero te dice no declarar variables y usted al hacer int myInt= 1; y ESTA declarando variable


hello i do not understand becaause you say do not declare any variables but you declare int myInt= 1;
int myInt 1;
you are declare please explain me


A post was merged into an existing topic: 11. Spinning, not accepting correct answer


i feel the same as ecaballero; probably just a bug er somfin like dah


I've tried answers above and still no clue what my problem is. I didn't got some error message while output showing my desired result. But the problem is, that "Run" button keep refreshing when I click it, which cause that "Next" button gray out and cannot go on. By the way, for some two boolean values without state values could be:
System.out.println(1<3 == 5>7)


Have you tried using a combination of true, false instead of those expressions?


I've found the reason why it was not working for me. Its because there is a "{" missing after "public static void main(String[] args)". If you put the "{" there the exercise will pass.