From https://stackoverflow.com/a/1079799
Java is by design not fit for duck typing. The way you might choose to do it is reflection:
public void doSomething(Object obj) throws Exception { obj.getClass().getMethod("getName", new Class<?>[] {}).invoke(obj); }
What does new Class<?>[] {}
mean? Thanks.