Java Advance Generic
Здравейте,някой може ли да ми каже защо ми дава тази грешка при първа и втора задача
това трябва да даде като отговор
java.lang.Integer: 7
java.lang.Integer: 123
java.lang.Integer: 42
А на мен ми дава това в Judge
java.util.ArrayList: [7, 123, 42]
java.util.ArrayList: [7, 123, 42]
java.util.ArrayList: [7, 123, 42]
Problem 1.Generic Box
Create a generic class Box that can store any type. Override the toString() method to print the type and the value of the stored data in the format {class full name: value}.
Use the class that you've created and test it with the class java.lang.String. On the first line you will get n - the number of strings to read from the console. On the next n lines, you will get the actual strings. For each of them create a box and call its toString() method to print its data on the console.
Examples
Input |
Output |
2 life in a box box in a life |
java.lang.String: life in a box java.lang.String: box in a life |
Problem 2.Generic Box of Integer
Use the description of the previous problem but now, test your generic box with Integers.
Examples
Input |
Output |
3 7 123 42 |
java.lang.Integer: 7 java.lang.Integer: 123 java.lang.Integer: 42 |
Задача 1
https://pastebin.com/ueb6rEEn
https://pastebin.com/gVgWzxDE
Задача 2
https://pastebin.com/KDbyJbiP
https://pastebin.com/Z0193NEr
Проблема е идентичен.
Благодаря !