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.
Hi. This is my first time here. It is really great!! It has solved a lot of questions of mine.Now I have one more question. Please help me. I am always confused about the assignments between primitives.I don't know when the casting is required.Here is my understanding and my questions. Please correct and answer me. double = int Yes int = double No float = double No double = float ?? int = long No long = int Yes How about the case in method call? e.g. Method(int x, int y) can I call it like Method(double, double)? How about the reverse? Thank you very much.
double = int Yes int = double No float = double No double = float ?? int = long No long = int Yes Ok when you are doing assignment think in this terms. The smaller type will always fit into a larger one right ? double = float yes you can. also remember if you don't specify float f = 10.2f with an f it will be treated as a double literal. Now about method call i didn't understand something. Do you mean if your method is designed to accept int values and you send it a double value what would happen ? It's a mistake to do this. And will result in an error. But if you pass to that method a short or a char they are going to be promoted to int values. I hope this helps.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com