What purpose do generic constructors serve in Java?

The use case I’m thinking of might be that some wants an Object which inherits from 2 Types. E.g. implements 2 interfaces:

public class Foo {

    public <T extends Bar & Baz> Foo(T barAndBaz){
        barAndBaz.barMethod();
        barAndBaz.bazMethod();
    }
}

Though I have never used it in production.

Leave a Comment