There are following difference between == and === operator in java.
== operator:-
This “==” operator check reference of two object, if reference pointing of two object are same memory location in heap, then it returns Boolean true otherwise false. The “==” operator is used for comparison.
public class OperatorTest {
public static void main(String[] args) {
String s1 = new String("welcome");
String s2 = new String("welcome");
String s3 = "hello";
String s4 = "hello";
// using "==" operator
System.out.println("check operator with new object reference :- " + (s1 == s2));
System.out.println("check operator with reference :- " + (s3 == s4));
}
}
Output :-
check operator with new object reference :- false
check operator with reference :- true
=== operator :-
This “===” operator is use in JavaScript. this equality operator is used to compare the values as well as the type of the two variables.
In below example a is an integer and b is a character type. when comparing a==b,Its return false.
In JavaScript
var a = 20;
var b = ’30’;
console.log(x === y)
Output :- false