int => string vs string => int

// integer => string type conversion
int i = -10;                    // -10
String str1 = Integer.toString(i); // “-10”
String str2 = String.valueOf(i); // “-10”
String str3 = new Integer(i).toString(); // “-10”

String str4 = String.format(“%d”, i); // “-10”

// string => integer type conversion
String x = “123”;          // “123”
int y = Integer.parseInt(x); // 123 (integer로 변환이 가능한 경우만 변환 가능 그 외엔 run-time exception error)
int z = Integer.valueOf(x); // 123 (integer로 변환이 가능한 경우만 변환 가능 그 외엔 run-time exception error)
int w = new Integer(x).intValue(); // 123 (integer로 변환이 가능한 경우만 변환 가능 그 외엔 run-time exception error)