Java Data Type Tutorial - Byte shortValue() example








Byte shortValue() returns the Byte as a short.

Syntax

shortValue has the following syntax.

public short shortValue()

Overrides

shortValue in class Number

Return

shortValue returns the short value from Byte.

Example

In the following code shows how to use Byte.shortValue() method.

public class Main {
  public static void main(String[] args) {
    Byte byteObject = new Byte("10");

    short s = byteObject.shortValue();
    System.out.println("short:"+s);
  }
}

The output: