"List cannot be resolved to a type." is the error message I get. I copied and pasted it from the web examples. I tried a few different ones. Why am I getting that error. The web examples are very simple and don't include libraries but I looked it up and I made sure to import the libraries as so:
Neither of the two list declarations work. What am I missing? I have bunch of other code ...main etc, but everything was working fine until I tried adding that list thing. The list declarations are outside of main, below the "import" declarations....there with my other variables. Any help would be appreciated.
Dick Hammer wrote:Doh I think we were both editing and posting at same time.
We were indeed
So Rob, I can in fact declare it as "List" and/or "ArrayList", but if I want to declare it as "List" I have to import java.util.List? And declaring it as "List" is better right?
Right on both accounts. The rule of thumb is, declare as broad as possible. If you declare as ArrayList you're stuck with that choice. You only should declare as ArrayList if you need one of the methods defined in ArrayList and not in List.