Java Integer byteValue() method


The byteValue() method returns the value of this Integer as a byte.

Following is an example to implement the byteValue() method in Java −

Example

public class Main {
   public static void main(String[] args) {
      Integer val = new Integer(10);
      byte res = val.byteValue();
      System.out.println("Value = " + res);
   }
}

Output

Value = 10

Let us see another example −

Example

import java.util.*;
public class Main {
   public static void main(String[] args) {
      Byte b = new Byte("10");
      byte res = b.byteValue();
      System.out.println("Byte = " + b );
      System.out.println("Primitive byte = "+ res);
   }
}

Output

Byte = 80
Primitive byte = 80

Updated on: 20-Sep-2019

141 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements