[Simon]: If java won't let one assign a double value to a float primitive; then why allow a Float Wrapper to be created from double primitive?
You can assign a double to a float - if you explicitly cast it to float. That means that, if you go to the extra effort to tell the Java compiler to go ahead and convert the double to a float, it will. It won't do this by default, but will if you explicitly tell it to. Similarly, you can explicitly specify that you want to convert a double to a Float, by explictly calling the constructor. The rules are not written to prevent you from ever converting a more precise data type to a less precise data type. They were jst written to make this a little bit harder, forcing you to explicitly acknowledge the conversion in some way. Calling the new Float(double) constructor is much like casting a double to a float - you're allowed to do it, as long as you tell the compiler that's really what you want.
"I'm not back." - Bill Harding, Twister
posted 13 years ago
Thanks for the reply. I understand what your saying, but I still disagree, see below.