em jan wrote:I failed the OCA 8 in the first attempt… now I feel too old and terribly exhausted to try again…am in my 40’s is that too old to try again … or should I stop being delusional and wait tables instead
I wrote:. . .
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
ArrayList cannot be resolved to a type
The method add(int, DataSet) in the type List<DataSet> is not applicable for the arguments (int, int)
. . .
Campbell Ritchie wrote:No, you will never see a keyword as the type; if you accidentally write a keyword, you will almost certainly get a different error message.
. . .
when I see "_______ cannot be resolved to a type" and what's in the blank is a Java keywordNo, the most likely explanation is that you have indeed got the imports right and have got a spellling errror sommewhere.
the most likely problem is that I need to import the right API/Class?
Paul Clapham wrote:You needed a List of DataSet objects, so you spent a dozen lines of code trying to do that. (And failed.) Here's a shorter way of producing the List you need:
That's Java 9; if you're still on Java 8 you'd need one line to create an empty List (like you did) and four lines to add those objects. Your main problem was that you didn't add DataSet objects to your List<DataSet>.
My bad... I reference the book title in the comment on line 2 of the code and my 2nd post in the thread is a pic of the code from the page. Now that I know there's an official way, I'll use it.
Campbell Ritchie wrote:.Please always tell us which book, etc. That would let us read it for ourselves.
. . .the book . . .