1

Let's say you've got a method which takes a class which is an instance of the interface Parent as the first and only parameter, just like this one:

public void doSomething(Parent parent) {}

Let's also say we've got a class Child which implements the interface Parent.

Why are many people using this method head:

public <T extends Parent> doSomething(T parent) {}

instead of this one:

public void doSomething(Parent parent) {}

Are there any advantages? Thanks for your help!

Adrian K.
  • 118
  • 1
  • 8
  • Actually, I am sorry, I googled a bit around for this question, but didn't find something similar so I thought it would be worth asking here. Sorry for the inconvenience and thanks for your help! //edit: flagged it myself as a duplicate, as it's solved. – Adrian K. Dec 14 '16 at 20:04

0 Answers0