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"
Joined: May 31, 2001
A basic way to put it is this: long stands for "long integer" It is simply an integer that can have a higher max value.
double stands for "double precision"(if I am not mistaken) It is float that can have more digit after the decimal. HTH,
Jason R. Kretzer<br />Software Engineer<br />System Administrator<br /><a href="http://alia.iwarp.com" target="_blank" rel="nofollow">http://alia.iwarp.com</a>
Joined: Dec 20, 2001
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
Joined: Dec 06, 2001
So is an Int an Object?
Joined: Feb 04, 2002
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