1 public class ChangeClass 2 { 3 public static void main(String[] args){ 4 5 //Int型数字转换成字符串 6 int num1=123456; 7 //方法1 8 String str1=num1+""; 9 System.out.println(str1); 10 //方法2 11 String str2=String.valueOf(num1); 12 System.out.println(str2); 13 14 //字符串中数字转换成Int型数字 15 String str3=new String("9876543"); 16 int num2=Integer.parseInt(str3); 17 System.out.println(num1+num2); 18 19 //字符转换成字符型数组 20 String str4="HRuinger"; 21 char a[]=str4.toCharArray(); 22 for(int i:a) 23 System.out.print((char)i+" "); 24 System.out.println(); 25 26 //字符型数组转换成字符串 27 char b[]={'H','R','u','i','n','g'}; 28 String str5=String.valueOf(b); 29 System.out.println(str5); 30 31 //整型与字符型数值的转换 32 char c='3'; 33 System.out.println(c-'0'); //此处也可以为c-48 34 int d=5; 35 System.out.println((char)(d+'0')); //此处也可以为c+48 36 } 37 }