This is my code.but my question why java is not supporting this operator where is other langauge is supporting like php,javascript.
int a=1;
float b=1;
if(a===b)
out.println("true");
else
out.println("false");
This is my code.but my question why java is not supporting this operator where is other langauge is supporting like php,javascript.
int a=1;
float b=1;
if(a===b)
out.println("true");
else
out.println("false");
PHP and JavaScript allow to check the type of a variable by using this operator. This isn't necessary in Java, because its typing is static.
The === operator performs a deep comparison and checks for type equality also. The equivalent in java is to override equals() and hashCode() to provide a contract that performs a deep equals() check. Java does not need a '==='.