Friday 19 July 2019

java - On what parameter '==' decides equality?




When we write the following code in Java:





object1 == object2;





on what basis does the operator '==' decide equality?


Answer




If object1 and object2 are reference types, then == checks if object1 and object2 are both references to the same object.



See 15.21 Equality Operators in the Java Language Specification for full details.


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...