The Float class wraps a value of the primitive type float in an object. An object of type Float contains a single field whose type is float.
Float data type is a single-precision 32-bit IEEE 754 floating point.
Float is mainly used to save memory in large arrays of floating point numbers.
Default value is 0.0f.
Float data type is never used for precise values such as currency.
Example: float myFloat = 234.5f
1. In the MainActivity.java file, add the below to the onCreate method. This will create a Float variable named myFloat.
float myFloat;
2. Compile and run!
Resources:
http://developer.android.com/reference/java/lang/Float.html
http://www.tutorialspoint.com/java/java_basic_datatypes.htm
Popular Posts
- Save LogCat to a Text File
- android:ellipsize - Add an ellipsis(...) in a TextView
- android:typeface - Set the Typeface to Sans, Serif, or Monospace in a TextView/EditText
- Intent setType(String type) - How to Set an Explicit MIME data type
- android:scrollbarStyle - Change the Scrollbar Location/Style in a TextView
- android:alpha - Set the Opacity/Transparency of Text in TextView/EditText
- How to Get Current Time in Milliseconds
- Perform an Action after Enter keypress on EditText
- Change the line spacing between lines of text in an TextView/EditText, using lineSpacingMultiplier
- Solution: error: Error parsing XML: unbound prefix