← Back to Generics
Question 186
Copy a Generic Value into a Box
Copy a Generic Value into a Box
Complete the generic methodcopyIntoBoxin theBoxToolsclass. It receives aBox<T>and a value of typeT, and should store that value in the box using itssetItemmethod. The fullBoxclass and the method signature are already provided. IMPORTANT: Do NOT write a main method. A hidden test will create String and Integer boxes, callcopyIntoBoxto update them, then print the new stored values usinggetItem().
Expected Output:
new value 50
= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
GenericsMethods
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.