answersLogoWhite

0


Best Answer

obj2 = true only if both has same memory location.

on the other hand equals() is a method defined in Object class and has overridden in many classes including String, Integer and provides logical equality e.g. two strings are equal by equals() method if there content are same.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

The single equals operator (=) signifies assignment.

This means set a equal to b
a = b

The double equals operator (==) signifies a comparison.

This evaluates whether or not a is equal to b.
a==b


Example:

// Assign a value to a
int a = 1;

// Assign a value to b
int b = 2;

// See whether or not a is equal to b
if( a == b ) {
System.out.println("They're equal!");

}else {
System.out.println("They're not equal!");

}


This distinction is important. Many new programmers will attempt to test the equality of a and b using the single equals operator. The problem is that if you say:

if(a=b)

What you're really doing is setting a equal to b. This is not really an issue in Java, since the compiler will detect this and display an error. However, if you move on to other languages (C/C++), this may very well cause problems. Using the above example in C would set a to the value of b, then return the new value of a. This would evaluate to true, which is not the desired behavior in this case.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

This would only be applicable in computer programing.

'=' is the 'assignment' operator. The term 'a=10' would be assigning the value '10' to the variable a.

'==' is the 'equal to' operator. The term 'a==10' would be testing if the value of the variable. It would generally be used in stating a condition in an 'if', 'while' or 'for' statement.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

(variable -= 10) is the same as saying (variable = variable - 10). The same exists for most other operators (+-*/%).

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How the equals operator differs from the equals equals operator?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Is x plus equals y is post increment or pre increment?

The '+=' operator behaves like a pre increment operator.


What character is used in an OR operator?

The logical OR operator in C and Java is the double vertical bar ().Example: if (s 0) do somethingThe operator applies a logical OR operator when it evaluates the expression.


What is the difference between you equals 10 and you equals equals 10 in c language?

The = operator is the assignment operator. The == operator is the equality or equals operator. The = operator is the assignment operator. We use it to assign a value (the right hand operand) to an object (the left hand operand). The value must be of the same type as the object unless the value can implicitly convert to the object's type. If not, we must explicitly cast the value to the appropriate type. The operator evaluates to the value of the object after assignment, thus creating a temporary value that can be used in other expressions. Examples: int you; you = 10; // assign the value 10 to the object named 'you' int me, you; me = 10; you = 10; Note that the second example can also be written: int me, you; me = you = 10; This is because the expression 'you = 10' evaluates to the temporary value 10 (the value of 'you' after assignment) which we then assign to 'me'. Operators are evaluated according to operator precedence, and assignment 'chains' like this are always evaluated from right to left. The == operator is the equality or equals operator. We use it to determine if two object's have the same value. If so, the expression evaluates true, otherwise false. Operators that evaluate true or false are known as Boolean operators (functions that return true or false are known as predicates). Typically we use the == operator in conditional expressions: if (a == b) { // code to execute when the value of a is equal to the value of b } else { // code to execute when the value of a is not equal to the value of b } while (a == b) { // This code will loop repeatedly so long as a is equal to b at the beginning of each iteration } The == operator is one of six Boolean operators that can be used to compare object values: == : equal != : not equal < : less than <= : less than or equal > : greater than >= : greater than or equal


What is the difference between the assignment operator and the equals operator?

The quality operator and the assignment operator are binary operators; they have two operands, one on either side of the operator. The equality operator is a Boolean operator which compares the two operands, returning true if they have the same logical state, otherwise false. E.g., x==y returns true if x and y have the same logical state, otherwise false. The operator is commutative, such that x==y is the same as y==x. The assignment operator sets the value of the left operand to that of the right operand, such that they both have the same logical state. After assignment, the left operand is returned. E.g., x=y returns x while y=x returns y. After the assignment, x==y must be true.


How do you find out not equals string in java?

Remember that strings are objects. You can use the String.equals method to determine equality, and use the ! (not) operator to test for inequality. public static boolean notEquals(String str1, String str2) { return !str1.equals(str2); }

Related questions

In excel if the formula equals A1 plus B1 what is the operator?

For =A1+B1, the operator is the plus sign (+).


How do you use equals equals equals operator in javascript?

'1' will return false because one variable is an integer and the other is a string.


Is x plus equals y is post increment or pre increment?

The '+=' operator behaves like a pre increment operator.


Difference between equals equals and equal in java?

"==" in java is the binary operator which compares two values and gives a boolean result While "=" in java is a assignment operator which assigns a value to a variable.


What is difference between equals and equals equals operators?

The equals operator is used for assigning a value to a variable. ex String name = "efu"; the equals equals operator is used for comparaing if the given value is equal to another value which is assigned for a variable. ex int i = 0; int j = 5; if( i == 0){ System.out.println(j+"can't be divided by"+i); }else{ System.out.println("answer is " +j/i); }


Is a syntax B1-B2B3 is an example of formula in excel?

No. There is no equals sign at the start and the cell reference B2B3 is not valid or has an operator missing. A possible formula variation on it could be:=B1-B2+B3No. There is no equals sign at the start and the cell reference B2B3 is not valid or has an operator missing. A possible formula variation on it could be:=B1-B2+B3No. There is no equals sign at the start and the cell reference B2B3 is not valid or has an operator missing. A possible formula variation on it could be:=B1-B2+B3No. There is no equals sign at the start and the cell reference B2B3 is not valid or has an operator missing. A possible formula variation on it could be:=B1-B2+B3No. There is no equals sign at the start and the cell reference B2B3 is not valid or has an operator missing. A possible formula variation on it could be:=B1-B2+B3No. There is no equals sign at the start and the cell reference B2B3 is not valid or has an operator missing. A possible formula variation on it could be:=B1-B2+B3No. There is no equals sign at the start and the cell reference B2B3 is not valid or has an operator missing. A possible formula variation on it could be:=B1-B2+B3No. There is no equals sign at the start and the cell reference B2B3 is not valid or has an operator missing. A possible formula variation on it could be:=B1-B2+B3No. There is no equals sign at the start and the cell reference B2B3 is not valid or has an operator missing. A possible formula variation on it could be:=B1-B2+B3No. There is no equals sign at the start and the cell reference B2B3 is not valid or has an operator missing. A possible formula variation on it could be:=B1-B2+B3No. There is no equals sign at the start and the cell reference B2B3 is not valid or has an operator missing. A possible formula variation on it could be:=B1-B2+B3


What character is used in an OR operator?

The logical OR operator in C and Java is the double vertical bar ().Example: if (s 0) do somethingThe operator applies a logical OR operator when it evaluates the expression.


What does 0x equals 17 mean?

There is no value of x that satisfies the equation. You may be missing an operator (+. - sign).


What is the difference between you equals 10 and you equals equals 10 in c language?

The = operator is the assignment operator. The == operator is the equality or equals operator. The = operator is the assignment operator. We use it to assign a value (the right hand operand) to an object (the left hand operand). The value must be of the same type as the object unless the value can implicitly convert to the object's type. If not, we must explicitly cast the value to the appropriate type. The operator evaluates to the value of the object after assignment, thus creating a temporary value that can be used in other expressions. Examples: int you; you = 10; // assign the value 10 to the object named 'you' int me, you; me = 10; you = 10; Note that the second example can also be written: int me, you; me = you = 10; This is because the expression 'you = 10' evaluates to the temporary value 10 (the value of 'you' after assignment) which we then assign to 'me'. Operators are evaluated according to operator precedence, and assignment 'chains' like this are always evaluated from right to left. The == operator is the equality or equals operator. We use it to determine if two object's have the same value. If so, the expression evaluates true, otherwise false. Operators that evaluate true or false are known as Boolean operators (functions that return true or false are known as predicates). Typically we use the == operator in conditional expressions: if (a == b) { // code to execute when the value of a is equal to the value of b } else { // code to execute when the value of a is not equal to the value of b } while (a == b) { // This code will loop repeatedly so long as a is equal to b at the beginning of each iteration } The == operator is one of six Boolean operators that can be used to compare object values: == : equal != : not equal < : less than <= : less than or equal > : greater than >= : greater than or equal


How do you solve 3x-y1 9x-3y equals -3?

It is not possible to give a sensible answer because the operator between y1 and 9x is not visible.


What are different types of operators?

The different types of operators are as follows: *Arithmatic operator *Relational operator *Logical operator *Assignment operator *Increment/Decrement operator *Conditional operator *Bitwise operator *Special operator


What is the difference between the assignment operator and the equals operator?

The quality operator and the assignment operator are binary operators; they have two operands, one on either side of the operator. The equality operator is a Boolean operator which compares the two operands, returning true if they have the same logical state, otherwise false. E.g., x==y returns true if x and y have the same logical state, otherwise false. The operator is commutative, such that x==y is the same as y==x. The assignment operator sets the value of the left operand to that of the right operand, such that they both have the same logical state. After assignment, the left operand is returned. E.g., x=y returns x while y=x returns y. After the assignment, x==y must be true.