In this post I will show you another interesting example of Java Dynamic Binding…

Did you expect such behavior? Feel free to comment. Thanks.
from Pocket http://ift.tt/1tMBluS
We all have used syntax’s like i += j and i = i + j thousands of times in our day to day programming. In first sight, they both look similar. In fact, they will result in same output in almost all of the cases in practical cases. But, to surprise you they are not similar.
Consider the following code snippet:
1 2 3 |
if (i == 15.0) { System.out.println("true"); } |
Which one of the following declarations of the variable i
will compile without errors and print true
when the program runs?
I will comment out the solution in the next few hours. Stay tunned.