Tag Archives: object

Simple example using object input / output streams and serialization

This is my first attempt at using Java to serialize and de-serialize an object. I’ve imported the classes individually (rather than java.io.*) just to make it clear what I’m using. The first code listing defines a new Person class that … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

A non-generic solution to box Java objects (bad programming)

Consider the following code that declares a new class to box (or wrap) an object inside another object. Declaring instance variable obj as an Object (the root class) allows us to add any object type. For example, As you can … Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment

How Java passes object references by value

In Java, a variable whose type is a class does not hold an object. Instead, it holds the memory location of the object, and this is called the object reference. The following example assigns a new object reference to a … Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment