Wednesday, June 10, 2026
HomeLanguagesJavaDouble floatValue() in Java with Examples

Double floatValue() in Java with Examples

The floatValue() method of Double class is a built-in method to return the value specified by the calling object as float after typecasting.

Syntax: 

DoubleObject.floatValue()

Return Type: It returns a float value i.e. the type casted value of the DoubleObject. 

Example 1:

Java




// Java Program to Implement floatValue() Method
// of Double Class
 
// Class
class GFG {
 
    // Main driver method
    public static void main(String[] args)
    {
 
        // Creating a Double object
        Double d = new Double(23);
 
        // Typecasting the value using
        // floatValue() method of Double class
        float output = d.floatValue();
 
        // Printing the double value on console
        System.out.println(output);
    }
}


Output:

Example 2:

Java




// Java Program to Implement floatValue() Method
// of Double Class
 
// Class
class GFG {
 
    // Main driver method
    public static void main(String[] args)
    {
 
        // Taking a double value by
        // creating object of Double class
        Double d = new Double(-1023.15);
 
        // Typecasting the value using
        // floatValue() method of Double class
        float output = d.floatValue();
 
        // Printing the above double value
        System.out.println(output);
    }
}


Output:

RELATED ARTICLES

2 COMMENTS

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6896 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7018 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS