[자바] ArrayList의 타입과 상속에 대해
자바를 오래동안 쓰고 있지만 제가 잘못 알고 있었던 것이 있네요. class People {} class Student extends People {} Student stt = new Student(); People ppl = stt; 자바에선 다형성(Polymorphism)을 지원하기에 위의 코드가 정상적으로 실행됩니다. 하지만 ArrayList에서 비슷하게 적용되진 않네요. ArrayList list_stt = new ArrayList(); ArrayList list_ppl = list_stt; 위의 코드는 에러를 발생 시킵니다. 타입이 일치하지 않으면 에러를 발생 시킵니다. Type mismatch: cannot convert from ArrayList to ArrayList ArrayList의 속..