| Author |
assignment operator : doubt.......
|
Parameswaran Thangavel
Ranch Hand
Joined: Mar 01, 2005
Posts: 485
|
|
char c = 65; double d = 10; if(c==d) i doubt how two different type are compared. Though it is a basic doubt i want some one to explain me about this....
|
 |
Sakthi Kani
Ranch Hand
Joined: Mar 29, 2005
Posts: 98
|
|
Hi U can compare the two different type. If both r compatible it returns true. So, in your code char and double r incompatible. hope u got it.
|
" Don't be afraid of pressure. Remember that pressure is what turns a lump of coal into a diamond... " <br /> <br />Thanks & Regards...<br />Sakthi<br />SCJP1.4, OCA
|
 |
Parameswaran Thangavel
Ranch Hand
Joined: Mar 01, 2005
Posts: 485
|
|
hi thank u for ur reply is the following code legal??? Object a = "hello"; String b = "hello"; if(a == b) System.out.println("equal"); else System.out.println("not equal");
|
 |
Sakthi Kani
Ranch Hand
Joined: Mar 29, 2005
Posts: 98
|
|
hi paramesh This is legal it gives the result as equal.Both object reference has the same hashcode, because both value r same. Check the following code to understand Now in this case, it has differnet hashcode.
|
 |
Parameswaran Thangavel
Ranch Hand
Joined: Mar 01, 2005
Posts: 485
|
|
|
can i say on using == the both operands should belong to the same hierarchy..
|
 |
Sakthi Kani
Ranch Hand
Joined: Mar 29, 2005
Posts: 98
|
|
Yes. whenever u get doubt, first u try it out with small sample program. Even then, u can't understand then post it. Because trying yourself will help u more than others explanation.
|
 |
 |
|
|
subject: assignment operator : doubt.......
|
|
|