public class IntegerDemo {
public static void main(String[] args) {
// int -- String
int num = 100;
// 方式1
String s1 = num + "";
//方式2
String s2 = String.valueOf(num);
//方式3
//int -- Integer -- String
Integer i = new Integer(num);
String s3 = i.toString();
//方式4
//public static String toString(int i)
String s4 = Integer.toString(num);
//String -- int
String s = "100";
//方式1
//String -- Integer -- int
//public int intValue()
Integer ii = new Integer(s);
int number1 = ii.intValue();
//方式2
//public static int parseInt(String s)
int number2 = Integer.parseInt(s);
}
}
|
|