The equal and == operator are used to compersion check and
both are returning the Boolean value(true or false)
For value type both of them are working same.
e.g.
int b= 10;
if(a==b) // true;
if(a.equal(b)) // true
But for reference type both of them are behaving different.
e.g
StringBuilder sb1 = new StringBuilder(“Value”);
StringBuilder sb2 = new StringBuilder(“Value”);
If(sb1 == sb2) // false
If(sb1.equal(sb2)) // true
No comments:
Post a Comment