What is the difference between Float, int, Double, Long, Short? I know its a dumb question, but i need to know the format that the number will be displayed. I do know that an int is an integer i.e. 5; and that Float has a decimal point i.e. 15.37; but what about the other?
Pete<br />"Reality is an illusion <br />brought on by a lack of <br />drink, drugs and smut"
Originally posted by Peter Phung: What is the difference between Float, int, Double, Long, Short?
Well, a quick answer is that, when you output a double, it will look a lot like a float (only with more decimal places) and a long and a short will look like an int. However, the terminology you're using is somewhat incorrect. Remember, Java is case sensitive. Float is different from float. A float is a Java primitive and a Float is an object that encapsulaates a float primitive. This is one of the "wrapper" classes. There is a wrapper class available for every one of the 8 primitive types and void. For the most part, the wrapper classes have the same names as the primitives they wrap, except that they have a capital first letter. For example, the wrapper for a float primitive is a Float object. The exceptions to this rule are the wrapper for an int primitive, which is an Integer object, and the wrapper for a char primitive, which is a Character object. Be sure to check out the API for all sorts of good information on these wrapper classes. I hope that helps, Corey
Numberical literals without a decimal point are assumed to be ints. Numberical literals with a decimal point are assumed to be doubles. To force a numerical literal to long, end it with an L (e.g. 100L). to force a numerical literal to a float, end it with an F (e.g. 100.0F). - Mike
Int is invalid Most of the wrapper classes follow the naming convention of "primitive name starting with a capital". Eg: primitive/wrapper class boolean/Boolean byte/Byte short/Short long/Long float/Float double/Double The two exceptions are integers and characters which are: int/Integer char/Character Regards, Matt
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