/**
* Compares this array with another array.
* <p>
* This is a requirement of the Comparable interface. It is used to provide
* an ordering for Array elements.
* @return a negative value if the provided array is "greater than" this array,
* zero if the arrays are identical, and a positive value if the
* provided array is "less than" this array.
*/
@Override
public int compareTo(Array s) {
// TODO - you fill in here (replace 0 with proper return
// value).
for (int i = 0; i < Math.min(s.size(), mSize); i++) {
if (this.mArray[i] != s.mArray[i]) {
return mArray[i] - s.mArray[i]; //FAIL HERE
}
}
return size() - s.size();
}
Error: The operator - is undefined for the argument type(s) Array<T>
, Array
. Can someone please tell me how do I return the difference between the 2 arrays element?
Thank you.