MCPcopy Create free account
hub / github.com/ShivaBhattacharjee/KeyZen / Box

Class Box

data/java/05_generics.java:1–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Box<T> {
2 private T value;
3
4 void set(T value) {
5 this.value = value;
6 }
7
8 T get() {
9 return value;
10 }
11
12 public static void main(String[] args) {
13 Box<Integer> scoreBox = new Box<>();
14 scoreBox.set(88);
15
16 Box<String> labelBox = new Box<>();
17 labelBox.set("Top score");
18
19 System.out.println(labelBox.get() + ": " + scoreBox.get());
20 }
21}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected