f.e: I have interface
C#
public interface Relatable { public int isLargerThan(Relatable other); }
class A implements Relatable{TypeScript
public int isLargerThan(Relatable other) { RectanglePlus otherRect = (RectanglePlus)other; // Why that way? if (this.getArea() otherRect.getArea()) return 1; else return 0;
}
class B implements Relatable{TypeScript
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
VulpesRank #55 · 29.2K reputationPosted Sep 19, 2011, 9:05 AM EDT
Sam HobbsRank #107 · 20.5K reputationPosted Sep 19, 2011, 2:32 PM EDT
AartiRank #2,383 · 594 reputationPosted Nov 16, 2011, 11:15 PM EST