Checks if the values of two operands are equal or not, if yes then condition becomes true.
Equality Test Operators ==, !=
The == operator tests if two values are the same, so (x == 6) is true if x contains the value 6. The not-equal operator, !=, is the opposite, evaluating to true if the values are different. Typically, you use == and != with primitives such as int and boolean, not with objects like String and Color. With objects, it is most common to use the equals() method to test if two objects represent the same value.
The similarity of == and .equals() can be confusing, so here is a suggested rule: Every value in Java is either a primitive (e.g. int) or an object (e.g. String). Use ==, <, >=, etc.. with primitives like int. Use .equals() with objects like String and Color. Since the dereference dot (.) only works with objects, you can remember it this way: if it can take a dot then use .equals() (e.g. a String), otherwise use == (e.g. an int).
It is also possible to use == with objects. In that case, what == does is test if two pointers point to exactly the same object. Such as use of == is a little rare in Java code, and so it's simpler to concentrate on using equals() with objects, and == only with primitives.