Hey my Dev Peeps,
So, I came across this line of Java code:
public AbstractEditor<? extends CoreConfig> getEditor(CoreConfig config) {...}
and was puzzled by the returned type being an extended object. I can't recall seeing this before. What does this mean? Why is this allowed in Java? Is this good coding?
Here's what I think.
The '?' is a wildcard <type> which allows any type to extend off the parent object (in this case, SourceConfig).
I like what this article response is specifically in referencing note from Effective Java:
http://stackoverflow.com/questions/18384897/what-is-difference-between-extends-object-and-e-extends-object
I also read this article which I think has some great, simple insight:
http://stackoverflow.com/questions/9646397/does-php-have-an-answer-to-java-style-class-generics
I'll need to investigate this more to conclude my quest...
No comments:
Post a Comment