Difference:
In Java, = is an assignment operation, while == is used to determine whether the values are equal.
Example:
a=b //就是把b的值赋予给a; a==b //就是判断a等于b
Judgment condition for judging whether the two values compared by the == operator are equal:
1 , if two values have the same type, then test for equality; if the two values are exactly the same, they are equal; if they are not exactly the same, then they are not equal.
2. If two values are of different types, they may still be equal. Use the following rules and type conversions to check their equality:
If one value is null and the other value is undefined, they are equal;
If one value is a number, the other value Is a string, convert the string into a number, and then use the converted value for comparison;
If a value is true, convert it to 1, and then compare. If a value is false, convert it to 0, and then compare;
If one value is an object and the other value is a number or string, convert the object into a primitive type value, and then compare;
Other combinations are not equal.
Recommended tutorial: java tutorial
The above is the detailed content of The difference between java = and ==. For more information, please follow other related articles on the PHP Chinese website!