리스트에 arraylist를 할당하는 코드를 작성중이었는데, 갑자기 arraylist가 할당이 안된다고
빨간줄이 가버렸다.
분명 arraylist는 list에 들어갈 수 있는 타입인데 왜? 라고 해서 검색을 좀 해봤다. 어딘가 이상한게 있을거라고는 생각했다. arraylist가 list에 못들어가는건데 내가 착각했을거라고는 생각하지 않았다. 왜냐면 늘상 써오던거라 아닐 리가 없었다.
그래서 보니 import를 잘못해준거였다.
import com.sun.tools.javac.util.List;
이걸 써줘버린 거였다.
그러니 에러가 난거다.
그래서
import java.util.List;
이걸로 바꿔주었다.
가끔씩 이런 문제가 생길땐 import있는곳을 좀 살펴봐야겠다. ctrl shift o 를 눌러서 import할때 그냥 무심코 급하게 엔터를 누르면서 import하다보니 엉뚱한게 import되서 종종 바꿔줘야하는 경우가 있었다.
이런 부주의는 의식적으로 줄일 수 있으니 조금 신경쓰는 것이 좋겠다.
https://kodlogs.com/76162/type-mismatch-cannot-convert-from-arraylist-to-list
Type mismatch: cannot convert from ArrayList to List. - Kodlogs
Problem: I have only this, but my compiler says:Type mismatch: cannot convert from ArrayList to List So what is the problem can anyone tell me ? I'm using Elipse Java EE IDE. Please help me to fix this.Thanks.
kodlogs.com