x = 5 means the value 5 of the RHs is assigned to the LHS variable x . Here = is the assignment operator. But x ==5, ==this is the relational (comparison) operator. Here it checks whether the value of RHS is equal to the value of LHS and this expression returns a boolean value as a result. It is the equality operation.