0

What is the difference between = and == ??

9th May 2017, 9:59 AM
Vishnuvasan
Vishnuvasan - avatar
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.
9th May 2017, 10:53 AM
Ayush Kumar Singh
Ayush Kumar Singh - avatar
+ 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.
9th May 2017, 10:48 AM
Patrick Schieber
Patrick Schieber - avatar
- 7
"=" is used to equalise two or more numbers... "==" is used to compare two or more numbers...
9th May 2017, 10:00 AM
Vishnuvasan
Vishnuvasan - avatar