Java: Method signature -
i want make interface mergeable
declares method merge()
. class implements have implement method follows:
someobject.java
public class someobject implements mergeable @override public someobject merge(someobject other) {...}
see return , parameter type set implementing class. there way enforce , how set method signature in interface?
look @ comparable
interface example. you'll have write like
interface mergeable<t> { t merge(t other); }
...and anytime want accept mergeable
, write
<t extends mergeable<t>> void somethingwithmergeables(t merge1) { ... }