//String --> int
//1: String --> Integer --> int
Integer in = new Integer("123");
int num = in.intValue();
System.out.println(num);
//public static int parseInt(String s)
int num2 = Integer.parseInt("12345");
System.out.println(num2);
//int --> String
//1: public static String valueOf(int i)
String s1 = String.valueOf(100);
System.out.println(s1);
//2:public static String toString(int i)
String s2 = Integer.toString(1000);
System.out.println(s2); |
|