-
-
Notifications
You must be signed in to change notification settings - Fork 549
Expand file tree
/
Copy pathBox.java
More file actions
23 lines (19 loc) · 573 Bytes
/
Box.java
File metadata and controls
23 lines (19 loc) · 573 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.bobocode.basics;
/**
* {@link Box} is a container class that can store a value of any given type. Using Object as a field type
* is flexible, because we can store anything we want there. But it is not safe, because it requires runtime casting
* and there is no guarantee that we know the type of the stored value.
* <p>
*/
public class Box<T> {
private T value;
public Box(T value) {
this.value = value;
}
public T getValue() {
return value;
}
public void setValue(T value) {
this.value = value;
}
}