개발/자바

java. incompatible types: int cannot be converted to java.lang.String(String 변수에 int형의 값을 넣으려고 하는 경우)

ttoance 2022. 8. 31. 21:40

이렇게 하니까 incompatible types 오류가 발생했다. 

int Num = (int) text;

 

Integer.valueOf 사용해서 고쳐주면 된다. 

int number = Integer.valueOf(text);

 

반응형

'개발 > 자바' 카테고리의 다른 글

java. 여러개의 port로 jar 파일 실행  (0) 2023.04.16
@bean vs @component  (0) 2022.10.27
spring. @responsebody vs @responseentity  (0) 2022.03.23
spring. 정적 컨텐츠  (0) 2022.03.23
intellij. 파일 목록 멀티 라인으로 표기  (0) 2022.01.12