Java Short.toString(short s) example

Java Short.toString(short s) example

By Yashwant Chavan, Views 13, Date 16-May-2018

In this java tutorial, You will learn how to use toString(short s) method of Short class. This method, Returns a new String object representing the specified short. The radix is assumed to be 10.

tags Java

Returns a new String object representing the specified short.

Syntax

public static String toString(short s)

Parameters

s - the short to be converted.

Returns

A string string representation of the specified short.

Java Short toString(short s) example

  • Assign two short values.
  • Create an instance of short values e.g new Short(value);
  • Short.toString(firstValue);It will return the string value of firstValue.
  • Short.toString(secondValue);It will return the string value of secondValue.
  • Print the values.
package com.technicalkeeda;

public class App {

	public static void main(String[] args) {

		short value = 50;
		Short firstValue = new Short(value);
		System.out.println("Value :- " + Short.toString(firstValue));

		value = -20;
		Short secondValue = new Short(value);

		System.out.println("Value :- " + Short.toString(secondValue));
	}
}

output

Value :- 50
Value :- -20

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]