The java.lang.Float.byteValue() is a built-in method in Java that returns the value of this Float as a byte(by casting to a byte). Basically it used for narrowing primitive conversion of Float type to a byte value.
public byte byteValue()
Parameters: The function does not accept any parameter.
Return Value: This method returns the Float value represented by this object converted to type byte.
Input : 12 Output : 12 Input : 1023 Output : -1
Below programs illustrates the java.lang.Float.byteValue() function:
Byte Value of num = -1 Byte Value of num = 12
Program 2 : Demonstrates the byte value for a negative number.
Byte Value of num = 1 Byte Value of num = -12
Program 3 : When a decimal value is passed in argument.
Byte Value of num = 11 Byte Value of num = 6
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.