-3

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");
Tim Pietzcker
  • 328,213
  • 58
  • 503
  • 561
ishwar
  • 444
  • 7
  • 20

2 Answers2

7

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.

jp_
  • 228
  • 2
  • 8
3

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 '==='.

Deepak Bala
  • 11,095
  • 2
  • 38
  • 49