目录

float floatValue()

描述 (Description)

java.lang.Byte.floatValue()以float形式返回此Byte的值。

声明 (Declaration)

以下是java.lang.Byte.floatValue()方法的声明

public float floatValue()

指定 (Specified by)

Number floatValue

参数 (Parameters)

NA

返回值 (Return Value)

此方法在转换为float类型后返回此对象表示的数值。

异常 (Exception)

NA

例子 (Example)

以下示例显示了lang.Byte.floatValue()方法的用法。

package com.iowiki;
import java.lang.*;
public class ByteDemo {
   public static void main(String[] args) {
      // create 2 Byte objects b1, b2
      Byte b1, b2;
      // create 2 float primitives f1, f2
      float f1, f2;
      // assign values to b1, b2
      b1 = new Byte("100");
      b2 = new Byte("-10");
      // assign float values of b1, b2 to f1, f2
      f1 = b1.floatValue();
      f2 = b2.floatValue();
      String str1 = "float value of Byte " + b1 + " is " + f1;
      String str2 = "float value of Byte " + b2 + " is " + f2;
      // print f1, f2 values
      System.out.println( str1 );
      System.out.println( str2 );
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

float value of Byte 100 is 100.0
float value of Byte -10 is -10.0
↑回到顶部↑
WIKI教程 @2018