โ Back to Interfaces
Question 620
A Generic Interface
A Generic Interface
Interfaces can be generic.IContainer<T>declaresvoid Add(T item)andT Get(int index). Complete the genericBox<T>class using an internalList<T>soAddstores an item andGetreturns the item at an index. Do NOT write aMainmethod. After adding"apple"then"banana", printing index 0 then index 1 gives: apple banana
Expected Output:
apple banana
Topics:
Interfaces
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.