class Main { class Foo { } interface GenericBase { } class GenericDerived implements GenericBase { } private void foo(GenericBase g) { } private void foo(GenericDerived g) { } void bar() { GenericDerived gd = new GenericDerived<>(); foo(gd); } }