Java Program to Convert a Short Integer Into a String

You are currently viewing Java Program to Convert a Short Integer Into a String

Java program to convert a short integer into a string

// Java program to convert a short integer 
// into a string

import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner X = new Scanner(System.in);
    String str;
    short shortVal = 0;

    System.out.print("Enter short value: ");
    shortVal = X.nextShort();

    //Convert short value into string.
    str = Short.toString(shortVal);

    System.out.println("String value: " + str);
  }
}

Output

Enter short value: 12345
String value: 12345

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply