Javatpoint Logo
Javatpoint Logo

Java Float byteValue() method

The byteValue() of Java Float class returns the value of this Float as a byte by narrowing the primitive values or in simple words by casting to a byte.

Syntax:

Parameters:

NA

Return Value:

This method returns the bytevalue which has been converted from the float value of this object.

Example 1

Test it Now

Output:

Sum = 60.44
Sum = 60

Example 2

Test it Now

Output:

float value = 10.5
Converted byte value by type casting = 10
Converted byte value by byteValue method=10

Example 3

Test it Now

Output:

Error:(16, 72) java: float cannot be dereferenced
-

Float is a primitive data type; its object cannot be used to call the Float class method. If you do this, you will get an error like above example.


Next TopicJava Float





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA