Eclipse message saying List cannot be resolved to a type
You can press Shift+Ctrl+O for auto importing.
Sometimes it may also be that the Java Build Path is not correctly set for your project.
Go to the project properties (Right click on project name in workspace and then click on Properties) and in the "Java Build Path" check if the JRE System Library
is set to unbound
.
If that's the case, change it to one of the Java SDK available on your machine. The address to download those is this one.
You will have to either import
the packages in which these classes are present, or write the entire path.
1. import :
import java.util.ArrayList;
import java.util.List;
2. Full path:
public class A {
java.util.List<Integer>
intList = new java.util.ArrayList<Integer>()
;
}
3. In Eclipse IDE,
use ctrl + shift + O
to import.
Put the following at the top of your source file:
import java.util.ArrayList;
import java.util.List;
Here is an explanation of what packages are and how the import
statement works.