Java.lang.Float.longValue() Method



Description

The java.lang.Float.longValue() method returns value of this Float as a long (by casting to type long).

Declaration

Following is the declaration for java.lang.Float.longValue() method

public long longValue()

Parameters

NA

Return Value

This method returns the float value represented by this object converted to type long.

Exception

NA

Example

The following example shows the usage of java.lang.Float.longValue() method.

package com.tutorialspoint;

import java.lang.*;

public class FloatDemo {

   public static void main(String[] args) {

      /* returns the float value represented by this object
         converted to type long */
      Float obj = new Float("9873267.90");
      long l = obj.longValue();
      System.out.println("Value = " + l);
    
      obj = new Float("10.0");
      l = obj.longValue();
      System.out.println("Value = " + l);
   }
}   

Let us compile and run the above program, this will produce the following result −

Value = 9873268
Value = 10
java_lang_float.htm
Advertisements