~/ learn/ java-from-zero/ cards/ Generic classes: type parameters and conventions
1 of 4

Type the Box<T> class declaration with a get method

Type the Box<T> class declaration with a get method

Answer

public class Box<T> { private T value; public T get() { return value; } }

T is a placeholder replaced by the actual type at each use site (Box<String>, Box<Integer>, etc.). The class itself stays generic.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/8fa37489-d406-4464-b339-c068afe9014a/flashcard utf-8 LF