1.String.valueOf(int i)方法
使用java String类的valueOf()方法进行转换。
示例:
public class test1 {
public static void main(String[] args) {
int test_int = 123456;
String test_str = String.valueOf(test_int);
System.out.println(test_str);
}
}
2.Integer.toString(int i)方法
使用java Integer类的toString()方法进行转换。
public class test1 {
public static void main(String[] args) {
int test_int = 123456;
String test_str = Integer.toString(test_int);
System.out.println(test_str);
}
}
3.加上空字符串的方法
public class test1 {
public static void main(String[] args) {
int test_int = 123456;
String test_str = test_int + "";
System.out.println(test_str);
}
}