MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / ObjectHolder

Class ObjectHolder

generics/ObjectHolder.java:6–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4// Visit http://OnJava8.com for more book information.
5
6public class ObjectHolder {
7 private Object a;
8 public ObjectHolder(Object a) { this.a = a; }
9 public void set(Object a) { this.a = a; }
10 public Object get() { return a; }
11 public static void main(String[] args) {
12 ObjectHolder h2 =
13 new ObjectHolder(new Automobile());
14 Automobile a = (Automobile)h2.get();
15 h2.set("Not an Automobile");
16 String s = (String)h2.get();
17 h2.set(1); // Autoboxes to Integer
18 Integer x = (Integer)h2.get();
19 }
20}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected