I have been reading examples of representations of Duck Typing in Java with reflection. I would like to know if this is correct:
public interface Quackable {
public void quack();
}
In main...
Object[] vec = {(Here I add some instances)};
for(int i=0; i < vec.length; i++) {
if(vec[i] instanceof Quackable)
vec[i].quack();
}