Java Short.byteValue() example

Java Short.byteValue() example

By Yashwant Chavan, Views 6, Date 24-Apr-2018

In this java tutorial, You will learn how to use byteValue() method of Short class. This method returns the numeric value represented by this object after conversion to type byte.

tags Java

Returns the value of this Short as a byte.

Syntax

public byte byteValue()

Returns

The numeric value represented by this object after conversion to type byte.

Java Short byteValue() example

  • Assign short value short value = 10;
  • Create an instance of short value new Short(value);
  • firstValue.byteValue();It will return the byte value of firstValue.
  • Print the byteValue.
package com.technicalkeeda;

public class App {

    public static void main(String[] args) {

        short value = 10;
        Short firstValue = new Short(value);

        byte result = firstValue.byteValue();

        System.out.println("byte value of firstValue :- " + result);
    }
}

output

byte value of firstValue :- 10

Suggested Posts

Yashwant

Yashwant

Hi there! I am founder of technicalkeeda.com and programming enthusiast. My skills includes Java,J2EE, Spring Framework, Nodejs, PHP and lot more. If you have any idea that you would want me to develop? Lets connect: yashwantchavan[at][gmail.com]