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?
"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.
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.
You can press Shift+Ctrl+O for auto importing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With