In this section, we're going to learn some very important things about how Java has chosen to implement object-oriented programming. We're going to be exploring the Object class itself. To get us started, I've written a really basic program:
package theobjectclass;
public class TheObjectClass {
public static void main(String[] args) {
MyClass object1 = new MyClass("abcdefg");
MyClass object2 = new MyClass("abcdefg");
object1.MyMethod();
object2.MyMethod();
System.out.println("The objects are the same: " +
(object1 == object2));
System.out.println("The objects are the same: " +
object1.equals(object2));
}
}
This program utilizes a custom class called MyClass and creates two instances of this class...