Let’s say I have the following ruby code :
def use_object(object) puts object.some_method end
and , this will work on any object that responds to some_method,right?
Assuming that the following java interface exists :
interface TestInterface { public String some_method(); }
Am I right to presume that interfaces are java’s way to achieving the same thing ( with the only difference that the parameter’s type would be TestInterface ) ?
You are right except that you can not define the body of a function in Java Interfaces, only prototypes.
Interfaces are the only way to implemente a pseudo multi-derivation in Java, since normal class derivation is only simple (just one parent).