Java Articles

Submit Article
Home » Articles » Java » FundamentalRSS Feeds

Float Wrapper Class

Posted By: Salvatore Kelly     Category: Java     Views: 6578

This article explains about Float wrapper class in java.

Float wrapper class is used to wrap primitive data type float value in an object. 

Example of Float Wrapper Class

Example 1 : Convert float to Float object

public class floatToFloat
  public static void main(String[] args) 
    float f = 1.2f;
    Float fObj = new Float(f);


This example shows how a float primitive value can be converted to a Float object.

Example 2  : Convert String to Float Object 

public class StringToFloat
  public static void main(String[] args) 
    Float fObj1 = new Float("1.2");
    String str1 = "2.4";
    Float fObj2 = Float.valueOf(str1);
    String str2 = "4.6";
    float f = Float.parseFloat(str2);


This example shows how we can convert String object to Float object.


Didn't find what you were looking for? Find more on Float Wrapper Class Or get search suggestion and latest updates.

Salvatore Kelly
Salvatore Kelly author of Float Wrapper Class is from Philadelphia, United States.
View All Articles

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

No Comment Found, Be the First to post comment!