Thursday, 18 May 2017

java - Why is "F" + "alse" not == "False"?

Essentially, only PDTs can be checked with ==. These are byte, short, int, long, float, double, boolean, char and of course, references. As the two references you get are different objects, the result would be false.



For any ADT (or object), you have to make use of the equals() method. All Java objects have them and you have to implement it for your own objects as well. For the String object this has been done for you and the characters are compared for to test equality.

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...