There are various way to convert integer to string:
package com;
public class IntegerToStringConversion {
/**
* @param args
*/
public static void main(String[] args) {
Integer intgerNum = 100;
String stringNum = intgerNum + "";//It uses more memory
System.out.println("Integer Num: " + intgerNum + " String Num: " + stringNum);
String stringNum1 = String.valueOf(intgerNum);//I prefer this
System.out.println("Integer Num: " + intgerNum + " String Num: " + stringNum1);
String stringNum2 = Integer.toString(intgerNum);//And this is also fine
System.out.println("Integer Num: " + intgerNum + " String Num: " + stringNum2);
}
}
Output:
Integer Num: 100 String Num: 100
Integer Num: 100 String Num: 100
Integer Num: 100 String Num: 100