~/ 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/6ec2b5f6-11c6-4de8-874b-58b5658e067f/flashcard utf-8 LF