0
What is the difference between = and == ??
3 Answers
+ 4
= is used to assign a value.
== is used to compare or to find if both of the value is equal or not.
+ 2
= is an assignment operator, so it is used to ASSIGN a value TO a variable.
== is a comparison operator, so it COMPARES the value from one variable TO another variable.
but be careful, as only simple datatypes can be compared with ==
for strings it may work, but better use str1.equals(str2) since it will always work.
- 7
"=" is used to equalise two or more numbers...
"==" is used to compare two or more numbers...