This Java program prompts the user to input a short integer value and then converts the short integer value to a string using the Short.toString() method. The resulting string is then printed to the console.
Here's a brief explanation of the program:
Note that the Short.toString() method is a static method that takes a short value as its argument and returns a String representation of that value.
import java.util.Scanner; public class ShortInt_ToString { public static void main(String[] args) { Scanner input = new Scanner(System.in); String str; short short_val = 0; System.out.print("Enter the Short Value : "); short_val = input.nextShort(); //Convert short integer to string str = Short.toString(short_val); System.out.println("String Value : " + str); } }
Enter the Short Value : 124 String Value : 124
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions