Wrap a Value With a Generic Factory Method
easyQuestion 495A factory method builds an object for you, so the caller never types new. The small generic class Box<T> is written. Complete the two generic static methods in Boxes. Each one declares its own type parameter T in front of its return type.
Requirements:
1. of(T item) creates a Box<T> that holds item and returns it.
2. unwrap(Box<T> box) returns the item stored inside box.
3. Do not change the Box class.
Do NOT write a main method.
Expected output
Box holding tea Box holding 12 4.5
= newline. The output ends with a newline, so print one after the last line.
Hints3 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.