Complete the code to declare a generic class named Box.
class Box<[1]> { var value: T? = null }
The generic type parameter is declared inside angle brackets after the class name. Here, T is the placeholder for any type.
Complete the code to create an instance of the generic class Box with type String.
val box: Box<[1]> = Box()To create a Box that holds Strings, specify String as the type argument.
Fix the error in the generic class declaration by completing the blank.
class Container<[1]> { fun getValue(): T? = null }
The generic type parameter must be declared as T to match its usage inside the class.
Fill both blanks to declare a generic class Pair with two type parameters.
class Pair<[1], [2]> { var first: A? = null var second: B? = null }
The class uses two generic type parameters named A and B to represent the types of the two values.
Fill all three blanks to declare a generic class Triple with three type parameters and properties.
class Triple<[1], [2], [3]> { var first: X? = null var second: Y? = null var third: Z? = null }
The class declares three generic type parameters X, Y, and Z matching the property types.