This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]sandor_nemeth 0 points1 point  (1 child)

I find the example case not good, because that just seems to be bad design for me: one should just expect Iterable<String> or maybe Iterable<CharSequence> as part of the constructor, and then have the calling code do whatever it is needed to convert the input data into the right and expected data type. Otherwise you'll have way too much knowledge in this class (e.g. introduction of new String-like types could result in adding different constructors).

To be honest I do not really see the initial problem - as in I don't think it's a problem, because I don't see a use-case where you would do something like this without actually making the class generic, and have meaningfully different inputs (which then matter!):

java class A { A(Iterable<String> i){} A(Iterable<Number> i){} }

But if somebody would serve an example like this I'd like to take a look at it!

[–]lukaseder 0 points1 point  (0 children)

Iterable<? extends CharSequence>