public interface Relatable { public int isLargerThan(Relatable other); }class A implements Relatable{
public int isLargerThan(Relatable other) { RectanglePlus otherRect = (RectanglePlus)other; // Why that way? if (this.getArea() < otherRect.getArea()) return -1; else if (this.getArea() > otherRect.getArea()) return 1; else return 0; }class B implements Relatable{
public Object findLargest(Object object1, Object object2) { Relatable obj1 = (Relatable)object1; Relatable obj2 = (Relatable)object2; if ( (obj1).isLargerThan(obj2) > 0) //Here Iam again using method but I dont declare it in that class, is it correct?? return object1; else return object2; }}Source: http://download.oracle.com/javase/tutorial/java/IandI/usinginterface.html