I am reading Effective Java , which has the following example. In the example below, the author copies the link to the objects present in the ObjectOutputStream object on the following line
byte[] ref = {0x71, 0, 0x7e, 0, 5};
Why does this link point to a date object present in an ObjectOutputStream? what is stored in the link?
import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.Date; final class Period { private final Date start; private final Date end; public Period(Date start, Date end) { this.start = new Date(start.getTime()); this.end = new Date(end.getTime()); if (this.start.compareTo(this.end) > 0) throw new IllegalArgumentException(start + " after " + end); } public Date start() { return new Date(start.getTime()); } public Date end() { return new Date(end.getTime()); } public String toString() { return start + " - " + end; }
source share