Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GenericsTester {
- public static void main(String[] args) {
- Box<Cake> cakeBox = new Box<>();
- Box<Pie> pieBox = new Box<>();
- Box<Tart> tartBox = new Box<>();
- cakeBox.put(new Cake());
- pieBox.put(new Pie());
- tartBox.put(new Tart());
- }
- }
- class Box<T> {
- private T t;
- public void put(T t) {
- this.t = t;
- }
- public T get() {
- return t;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement