I have a class ObjectX, and two objects of that same class objectX1, and objectX2.
I also have a method that checks which of two objects of that class is the biggest. Each object of the class consists in a large number stored in an arrayList.
Here's the method declaration:
public ObjectX bigger(ObjectX objectX2);
This method is working just fine, it takes another object besides the one from the class itself, and returns which one is the biggest.
My problem though is when i try to call that method inside an if statement, like this:
public static void main(String[] args) {
if((this.bigger(object2)) == this)
System.out.println("First is bigger!");
else if((this.bigger(object2)) == object2)
System.out.println("Second is bigger!");
else
System.out.println("The objects are equal!");
}
The if statement does not check as it was supposed to. How can i solve this ?