Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse message saying List cannot be resolved to a type

Tags:

java

eclipse

I am trying the following code in eclipse:

public class A {         List<Integer> intList = new ArrayList<Integer>(); } 

However it gives me an error saying: List cannot be resolved to a type and ArrayList cannot be resolved to a type.

Is there some library I need to add and how do I do that?

like image 952
Alan2 Avatar asked Jun 16 '12 17:06

Alan2


People also ask

What does it mean when something Cannot be resolved to a type?

"cannot be resolved to a type" means that the compiler has decided that, according to the syntax of the language, what it found at this place in the code has to be type, which means either a class, an interface, or a primitive tpye, but cannot find the definition of any type with that name.

What does Cannot be resolved to a variable mean in Java?

Fix the cannot be resolved to a variable Error in Java If you try, the cannot be resolved to a variable error will come out. It means it cannot detect the initialization of variables within its scope. Similarly, if you make a private variable, you cannot call it inside a constructor. Its scope is out of bounds.


1 Answers

You can press Shift+Ctrl+O for auto importing.

like image 166
christian.vogel Avatar answered Sep 24 '22 05:09

christian.vogel