import java.util.*; import java.io.*; import java.math.*; import java.math.*; public class Main { public static void main(String []args) { int num=11; //10->2 String str=Integer.toBinaryString(num); System.out.println(str); //10->8 str=Integer.toOctalString(num); System.out.println(str); //10->16 str=Integer.toHexString(num); System.out.println(str); //10->特定进制 int random=(int)(Math.random()*10); str=Integer.toString(num,random); System.out.println(str); //2->10 str="1011"; num=Integer.parseInt(str,2); System.out.println(num); //8->10 str="13"; num=Integer.parseInt(str,8); System.out.println(num); //16->10 str="b"; num=Integer.parseInt(str,16); System.out.println(num); System.out.println("********************"); //数值类型和String类的转换 int a=0; String b="12345"; a=Integer.valueOf(b); System.out.println(a); a=12345; b=String.valueOf(a); System.out.println(b); //Integer.valueof()返回的是Integer对象 //Integer.parseInt()返回的是int } }