The java.lang.Byte.longValue() returns the value of this Byte as a long.
Following is the declaration for java.lang.Byte.longValue() method
public long longValue()
longValue in class Number
NA
This method returns the numeric value represented by this object after conversion to type long.
NA
The following example shows the usage of lang.Byte.longValue() method.
package com.tutorialspoint; import java.lang.*; public class ByteDemo { public static void main(String[] args) { // create 2 Byte objects b1, b2 Byte b1, b2; // create 2 long l1, l2 long l1, l2; // assign values to b1, b2 b1 = new Byte("127"); b2 = new Byte("-128"); // assign long values of b1, b2 to l1, l2 l1 = b1.longValue(); l2 = b2.longValue(); String str1 = "long value of Byte " + b1 + " is " + l1; String str2 = "long value of Byte " + b2 + " is " + l2; // print l1, l2 values System.out.println( str1 ); System.out.println( str2 ); } }
Let us compile and run the above program, this will produce the following result −
long value of Byte 127 is 127 long value of Byte -128 is -128