Java Integer byteValue() Method Last Updated : 06 May, 2022 Comments Improve Suggest changes Like Article Like Report The byteValue() method of Integer class of java.lang package converts the given Integer into a byte after a narrowing primitive conversion and returns it (value of integer object as a byte). Also, remember this method does override byteValue() method of the Number class. The package view is as follows: --> java.lang Package --> Integer Class --> byteValue() Method Syntax : public byte byteValue() Return Type: Returns the numeric value represented by this object after conversion to byte type. Note: It is compatible with Java 1.5 and onwards. Example 1: Java // Java program to Illustrate byteValue() Method // Of Integer Class // Importing required class import java.lang.Integer; // Main Class class GFG { // Main driver method public static void main(String args[]) { // Creating an Integer object and // passing custom integer input Integer a = new Integer(34); // Converting integer number to byte value // using byteValue() method byte b = a.byteValue(); // Printing the corresponding byte value System.out.println(b); } } Output:34 Example 2: Java // Java Program to Illustrate byteValue() Method // of Integer Class // Importing required classes import java.lang.*; import java.util.*; // Main Class class GFG { // Main driver method public static void main(String[] args) { // Creating a Byte object Byte b = new Byte("01"); // Converting Byte to byte primitive // using byteValue() method Byte bp = b.byteValue(); // Display statement System.out.println("Byte object : " + b); // Primitive byte value of custom Byte passed above String str = "Primitive byte value of Byte object : " + bp; // Printing byte primitive value System.out.println(str); } } Output:Byte object : 1 Primitive byte value of Byte object : 1 Comment More infoAdvertise with us Next Article Java Integer byteValue() Method N Niraj_Pandey Follow Improve Article Tags : Java Java-lang package Java-Functions Java-Integer Practice Tags : Java Similar Reads Integer hashCode() Method in Java The java.lang.Integer.hashCode() method of Integer class in Java is used to return the hash code for a particular Integer . Syntax: public int hashCode() Parameters : The method does not take any parameters. Return Value: The method returns a hash code integer value for this object, which is equal t 2 min read BigDecimal byteValueExact() Method in Java The java.math.BigDecimal.byteValueExact() is an in-built function which converts the BigDecimal to a byte and checks for lost information. Any BigDecimal value greater than 127 or less than -128, will generate an exception as it doesn't fit in byte range. Syntax: public byte byteValueExact() Paramet 2 min read Byte intValue() method in Java with examples The intValue() method of Byte class is a built in method in Java which is used to return the value of this Byte object as int. Syntax ByteObject.intValue() Return Value: It returns the value of ByteObject as int. Below is the implementation of intValue() method in Java: Example 1: Java // Java code 2 min read Byte byteValue() method in Java with examples The byteValue method of Byte class is a built in method in Java which is used to return the value of this Byte object as byte. Syntax ByteObject.byteValue() Return Value: It returns the value of ByteObject as byte. Below is the implementation of byteValue() method in Java: Example 1: Java // Java co 2 min read Short byteValue() method in Java with Example The java.lang.Short.byteValue() method of Short class is a built in method in Java which is used to return the value of the Short object as a byte. Syntax ShortObject.byteValue() Return Value: It return the value of ShortObject as byte. Below is the implementation of byteValue() method in Java: Exam 2 min read Array getByte() Method in Java The java.lang.reflect.Array.getByte() is an inbuilt method in Java and is used to return the element present at the given index from the specified Array as a Byte.Syntax: Array.getByte(Object []array, int index) Parameters : This method accepts two mandatory parameters: array: The object array whose 3 min read BigDecimal doubleValue() Method in Java The java.math.BigDecimal.doubleValue() is an in-built function which converts the BigDecimal object to a double. This function converts the BigDecimal to Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY as appropriate or according to the passed object, if its magnitude is too big to be represent 2 min read Byte floatValue() method in Java with examples The floatValue() method of Byte class is a built in method in Java which is used to return the value of this Byte object as float. Syntax ByteObject.floatValue() Return Value: It return the value of ByteObject as float. Below is the implementation of floatValue() method in Java: Example 1: Java // J 2 min read Float byteValue() method in Java with Examples 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. Syntax: public byte byteValue() Parameters: The function does not accept any paramete 2 min read Number.byteValue() Method in Java with Examples The Number class in Java is an abstract superclass for numeric wrapper classes like Integer, Float, Double, etc. One of the useful methods provided by this class is byteValue(). The Number.byteValue() method in Java is used when we want to extract the byte representation of a numeric object.The byte 3 min read Like