This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
One thing you need to know is that a cast between unrelated class and interface is allowed. The cast may fail at runtime but at compile time its allowed. Look at this casting tutorial for more info. Other casts should be simple to understand...
This is an excellent tutorial.
Hi Ankit, In your tutorial at http://www.javaclubindia.com/core-java/difference-between-object-and-reference-in-java at second diagram, you represented name="Eric" string within Heap which I feel may not correct. What I am trying to say is when we say, String name="Eric", Eric should be created in string constant/memory pool and when we say String name = new String("Eric"), Eric should be created on Heap know ? Please advice if I am wrong.
Harikrishna lets keep the discussion in this topic to mohit's problem. If you have any doubt start a new topic. Mohit, what exactly are you facing problem with. You've shown about 6 statements which you don't understand. Can you tell us what you think is happening in those statements, and then we'll tell you if you are right or wrong...
Ankitwhat exactly are you facing problem with. You've shown about 6 statements which you don't understand. Can you tell us what you think is happening in those statements, and then we'll tell you if you are right or wrong...,
i am no able to understand any of the lines.i am posting the first 2 initally
m is Interface that is implemeted by b
then,its cast to c
what does this casting exactly means
we are casting from Supertype to subtype and then assiging the cast to another subtype that is supertype of resultant cast
shouldn't the cast be same as that of reference
Here m is first downcasted to type C and then implicitly upcasted to type B.
The cast here is not required, if you omit it there will be an automatic upcasting.
This cast falls under the category that I was referring to. Type A and Min are not related still this cast compiles fine as a cast between unrelated class and interface is allowed. Now try to figure out the rest of them...