Can't Solve this error

I’m new to java and can’t figure out how to solve this error:i

Repl link:
here is a screenshot of the error and the code

1 Like

I’m not that familiar with java, but it looks like when you run this code there is a problem here.

List<String> shopping_list = new ArrayList<String>();

It looks to me like you are defining the variable shopping_list as a List type, but then the object you are storing in it is an ArrayList type, and I would assume that this is the problem. Try this instead.

ArrayList<String> shopping_list = new ArrayList<String>();
1 Like

The error seems to be that Java cannot resolve the type List.

Try adding:

import java.util.List;

at the top with your other imports.

(ArrayList inherits from List which is why you can declare an ArrayList<String> instance as a variable of the type List<String>)