dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Java Language
Expertise: Beginner
Mar 20, 1997

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Difference Between 'float' and 'Float' Types

Question:
What is the difference between the types 'float' and 'Float' in Java?

Answer:
A variable of type float contains an IEEE single precision number, while a variable of type Float contains a pointer to an object encapsulating an IEEE single precision number.

The class Float is called an object wrapper of the type float. The designers of Java found it convenient to introduce object wrappers for all the primitive types: int:Integer, boolean:Boolean, etc.

This is convenient for representing heterogeneous collections of primitive values. For example, it's easy to create an array containing an odd assortment of objects since all objects can be implicitly cast to the class Object.

Object[] things; // holds instances of Bike, Shoe, Gum,
etc. 
On the other hand, there is no "most general type" to which all primitive values can be promoted. (Every primitive value can be promoted to a double except booleans.)
double[] items; //
holds numbers, chars, but not booleans
However, things can hold instances of Boolean, Char, and Number.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date