해당 함수를 사용할 경우 문자열을 기본 정수 (int)로 변환해준다.
parseInt(string, radix);
Parameter
public class StringToInt {
public static void main(String[] args) {
String str1 = "123";
String str2 = "0xF";
int intValue1 = Integer.parseInt(str1);
int intValue2 = Integer.parseInt(str2, 16);
System.out.println(intValue1); // 123
System.out.println(intValue2); // 15
}
}
public class IntToString {
public static void main(String[] args) {
int intValue1 = 1234;
int intValue2 = 1234;
String str1 = Integer.toString(intValue1);
String str2 = String.valueOf(intValue2);
System.out.println(str1); // 1234
System.out.println(str2); // 1234
}
}