A box can hold one value. The type of the value is decided when the box is made, so the same class must work for numbers, words and anything else.
Write a generic class Box<T> with:
Box(T value) that stores the value,get() that returns the stored value,set(T value) that replaces the stored value.The main code makes one box of numbers and one box of words, changes both, and prints them.
n (between -1000000 and 1000000).! was added at the end of the word.Input:
5
hello
Output:
10
hello!

A box can hold one value. The type of the value is decided when the box is made, so the same class must work for numbers, words and anything else. Write a generic class `Box<T>` with: - a constructor `Box(T value)` that stores the value, - a method `get()` that returns the stored value, - a method `set(T value)` that replaces the stored value. The main code makes one box of numbers and one box of words, changes both, and prints them. ### Input Format - Line 1: an integer `n` (between -1000000 and 1000000). - Line 2: one word (no spaces). ### Output Format - Line 1: the number box after it was doubled. - Line 2: the word box after `!` was added at the end of the word. ### Example Input: ``` 5 hello ``` Output: ``` 10 hello! ``` Write a generic method `static <T> int countEqual(T[] items, T target)` that returns how many elements of `items` are equal to `target`. Compare with `equals`, not with `==`. The same method must work for an array of `Integer` and an array of `String`. Words are compared exactly, so `Hi` and `hi` are different. ### Input Format - Line 1: an integer `n` (at least 1), the count of numbers. - Line 2: `n` integers. - Line 3: one integer, the number to look for. - Line 4: an integer `m` (at least 1), the count of words. - Line 5: `m` words. - Line 6: one word, the word to look for. ### Output Format - Line 1: how many times the number appears. - Line 2: how many times the word appears. ### Example Input: ``` 5 3 7 3 9 3 3 4 red blue green red red ``` Output: ``` 3 2 ``` A pair holds two values, and the two values can have different types. Write a generic class `Pair<A, B>` with: - a constructor `Pair(A first, B second)`, - `A getFirst()` and `B getSecond()`, - a method `swap()` that returns a **new** pair with the two values exchanged, so its type is `Pair<B, A>`. The original pair does not change. ### Input Format - Line 1: an integer, a roll number. - Line 2: a name (one word). ### Output Format - Line 1: the first and second value of the original pair, with one space between them. - Line 2: the first and second value of the swapped pair, with one space between them. - Line 3: the length of the first value of the swapped pair (the name). ### Example Input: ``` 12 Asha ``` Output: ``` 12 Asha Asha 12 4 ```