Thanks and Regards, Amit Taneja
SCJP 1.4
Thanks and Regards, Amit Taneja
Thanks and Regards, Amit Taneja
...there is Double is comparing with Integer ? will it not produce error..as it written in some eg. of K&B
but K&B also wrote that it will produce compiler error when we compare differnt objects ?
SCJP 1.4
Thanks and Regards, Amit Taneja
SCJP 1.4
They have to be explicitely casted to a common base class. (Or you can cast one, and let Java implicitely cast the other)
SCJP 1.4 (88%)<br />SCWCD 1.4 (88%)
Thanks and Regards, Amit Taneja
Originally posted by jas oberai:
Henry,
Can you just show this with some code from the above example,so that we should not get any compiler error.This == and equals thing really gets confusing at times.Thanks
And BTW, this exercise is kinda pointless. If you need a cast to a common base class, you kinda know the result. The condition will report false -- as there is no way they can be the same reference.
Let me know if this is clear, or if you still have doubts, there are a lot of other things to say about equals and ==, that part might be confusing on K&B at the beginning, but if you try a lot of examples, you will get it!
This explanation is just the basic you MUST understand in order to grasp the other concepts.
SCJP 1.4
Thanks and Regards, Amit Taneja