Java Float longValue()方法及示例
Float类中的 java.lang.Float.longValue() 方法是Java中的一个内置方法,在类型转换后返回调用对象指定的长值。
语法
public long longValue()
参数: 它不需要任何参数。
返回类型: 它返回一个 长值 ,即FloatObject的类型转换值。
下面是上述方法的实现。
程序1 :
// Java Code to implement// longValue() method of Float class class GFG { // Driver method public static void main(String[] args) { // creating a Float object Float d = new Float(1022); // longValue() method of Float class // typecast the value long output = d.longValue(); // printing the output System.out.println(output); }}
输出。
1022
程序2
// Java Code to implement// longValue() method of Float class class GFG { // Driver method public static void main(String[] args) { // creating a Float object Float d = new Float(-1023.23); // longValue() method of Float class // typecast the value long output = d.longValue(); // printing the output System.out.println(output); }}输出。
-1023
参考资料: https://docs.oracle.com/javase/7/docs/api/java/lang/Float.html#longValue()
