This program demonstrates that the instance variables ofobject1andobject2are identical.
The output is shown here:
object1: s=Hello; i=-7; d=2.7E10
object2: s=Hello; i=-7; d=2.7E10
Stream Benefits
The streaming interface to I/O in Java provides a clean abstraction for a complex and often
cumbersome task. The composition of the filtered stream classes allows you to dynamically
build the custom streaming interface to suit your data transfer requirements. Java programs
written to adhere to the abstract, high-levelInputStream,OutputStream,Reader, and
Writerclasses will function properly in the future even when new and improved concrete
stream classes are invented. As you will see in the next chapter, this model works very well
when we switch from a file system–based set of streams to the network and socket streams.
Finally, serialization of objects plays an important role in many types of Java programs.
Java’s serialization I/O classes provide a portable solution to this sometimes tricky task.
598 Part II: The Java Library