카테고리 없음
[Java] String to int, int to String
321
2021. 2. 13. 16:57
1. String을 int로 변환
String test = "123";
int convert = Integer.parseInt(test);
숫자형이 아닌 변수를 변환하려 시도한다면,
ex)
String test1 = "메롱";
int convert1 = Integer.parseInt(test");
NumberFormatException이 뜬다
2. int를 String으로 변환
int test = 123;
String convert = String.valueOf(test);
- int는 원시타입이고, String은 문자열인뎀..