You are given an integer , you have to convert it into a string.
Answers
Answered by
0
Convert using Integer.toString(int)
The Integer class has a static method that returns a String object representing the specified int parameter. Using this is an efficient solution.
Syntax
public static String toString(int i)
The argument i is converted and returned as a string instance. If the number is negative, the sign will be preserved.
Example
int number = -782;
String numberAsString = Integer.toString(number);
The code is equivalent to:
String numberAsString = "-782";
The Integer class has a static method that returns a String object representing the specified int parameter. Using this is an efficient solution.
Syntax
public static String toString(int i)
The argument i is converted and returned as a string instance. If the number is negative, the sign will be preserved.
Example
int number = -782;
String numberAsString = Integer.toString(number);
The code is equivalent to:
String numberAsString = "-782";
Similar questions