Page 1 of 1

[HD Pg 356, Sec. 12.4.2 - arraylist-api]

Posted: Tue Apr 30, 2019 4:40 am
by flex567
Observe that the type of the variables in the above code is List and not ArrayList. This is because the return type of asList is List. Although you will not be tested on this method in the exam, you may see code that uses this method to build an ArrayList with a few elements in a single statement.
How can the return type be a List if List is an interface?

Re: [HD Pg 356, Sec. 12.4.2 - arraylist-api]

Posted: Tue Apr 30, 2019 4:55 am
by admin
Because an interface is also a type. See 1.1.3 Type, class, enum, and interface.

Re: [HD Pg 356, Sec. 12.4.2 - arraylist-api]

Posted: Tue Oct 15, 2019 12:58 pm
by DazedTurtle
The index value must lie between 0 and the list's current size (both inclusive)
Wouldn't it be inclusive for 0, and exclusive for the size?

[1, 2, 3] would have size 3, right? So if the index must be between 0 and the size, both inclusive, then that would make 0, 1, 2, and 3 valid indices. But 3 would be out of bounds, wouldn't it?

Edit: Also, something seems to be off about the character encoding? Here's a screenshot, since it has weird characters and I can't copy and paste.
studyGuideEncoding.png
studyGuideEncoding.png (29.5 KiB) Viewed 1632 times
This in Kindle Cloud Reader, in Google Chrome.

Re: [HD Pg 356, Sec. 12.4.2 - arraylist-api]

Posted: Tue Oct 15, 2019 9:39 pm
by admin
1. Actually that text is about the add method but it is not mentioned so. It will be improved.
2. The junk characters should be removed.

thank you for your feedback!