018-003-002
Generic Storage Box
Easy
Problem Description
In this problem, you will implement the Box<T> class that manages object state through fields such as item. Create a generic Box<T> class that can store any type of object. Implement store(T item) to put an item and get() to retrieve it.
Test Cases
※ Output examples follow programming industry standards
Normal case
Input:
new Box<>(); box.store("Hello"); box.get()Expected Output:
Hello
Normal case
Input:
new Box<>(); box.store(42); box.get()
Expected Output:
42
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here
sc.close();
}
}
0 B / 5 MB
You have 10 free executions remaining
