educative.io

Educative

ArrayList: Iteration example does not compile

ArrayList: Iteration example does not compile

Line List list = new ArrayList();
to be corrected to
List list = new ArrayList();

Error message:
ArrayListDemo.java:17: error: incompatible types: Object cannot be converted to Integer
for (Integer i : list) { //Enhanced for loop


Type your question above this line.

Course: https://www.educative.io/collection/6650775272947712/6368023997317120
Lesson: https://www.educative.io/collection/page/6650775272947712/6368023997317120/6260868656922624

Hello @Gyumi_Vegyi,

Thank you for pointing out the mistake. The correct code line List <Integer> list = new ArrayList<Integer>(); has been updated inside the lesson.

Hope this helps!