CJCoding With Joseph
15free / daySign inCreate account

Shelf<T> keeps its items in a private ArrayList<T>, so one shelf class can hold books, scores or anything else. The list field and size() are written. Complete the other three methods. Each one is a single call on the list.

Requirements: 1. add(T item) puts item at the end of the shelf. 2. get(int index) returns the item at that position. The first item is at index 0, and the tests only ask for positions that exist. 3. has(T item) returns true when the shelf holds an equal item, otherwise false.

Do NOT write a main method.

Expected output

3
Dune
Ulysses
true
false

= newline. The output ends with a newline, so print one after the last line.

Hints4 available
Topics
GenericsClasses
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.