I'm trying to write a method for a dynamic array class that compares the size of the current dynamic array to the one passed in from the method. The issue i'm having is that the type in the method argument is of type Object, and while it is assumed to be of the same type as the array i'm comparing it to, Java doesn't know that. I've tried casting it, but it doesn't seem to be working. Any help would be greatly appreciated. Here's the basic method header also it should be noted that the object using this method is a DynamicArrayOfInts object and I have to use Object aThat in the argument for the method:
public boolean equals(Object aThat) { // aThat is a DynamicArrayOfInts object if(this.size!=aThat.size) //i know this is wrong return false; // added so code would compile }