java.lang.Byte floatValue()


The floatValue() method of Byte class returns the value of this Byte as a float after a widening primitive conversion.

Important Notes:

  • The method floatValue() is specified by floatValue in class Number

Method Syntax

public float floatValue()

Method Argument

Data Type Parameter Description

Method Returns

The floatValue() method of Byte class returns the numeric value represented by this object after conversion to type float.


Requires Java 1.1 and up

Java Byte floatValue() Example

Below is a simple java example on the usage of floatValue() method of Byte class.


import java.util.Scanner;

 * This example source code demonstrates the use of 
 * floatValue() method of Byte class.

public class ByteFloatValueExample {

	public static void main(String[] args) {

		 * Editor's Note
		 * Be extra careful in using this method
		 * as it uses widening concept
		// ask for user input
		System.out.print("Enter a number:");

		// read the user input
		Scanner s = new Scanner(;
		String value = s.nextLine();
		Byte byteValue = new Byte(value);
		// convert byteValue into float
		float result = byteValue.floatValue();
		System.out.println("float value is "+result);



Basically on the above example, we have asked the user to enter a number on the console. Internally the input value is assign to a Byte object. We then use the floatValue() method to convert it into type float. It doesn’t do much however it shows the basic behaviour of this method.

Sample Output

Below is the sample output when you run the above example.

java Byte floatValue() example output