It didn't come across as rude to me. And i think it's entirely accurate.
Moreover, that pattern - of sending a variable with a wildcard type argument into a method with a type parameter so that the type argument gains a name - is a something i've seen and used many times, and is useful to know. I don't know if there is a name for this technique, but i call it "taming a wildcard".
In the example case, though, it isn't about giving it a name. It is about using the name in the first place. Is no different from:
class Foo {
void test(String arg) {..}
main(..) {
Foo foo = new Foo();
Object s = "sd";
foo.test(s); // Boom
}
}
Note that if that were instead: class Foo {
void test(Number arg) {..}
main(..) {
Foo foo = new Foo();
Long n = 4L;
foo.test(n);
}
}
Then things work, because the subtyping is chosen. In the generics case, there is no relation between Foo<Number> and Foo<Integer>. If there were, then the capture could potentially treat Foo<?> as Foo<Object> and then depending on if you went co or contra, could allow the call.I'm both sorry and baffled you found my response rude. As for your question, I'm afraid I don't understand it whatsoever. What am I supposed to be choosing? What does your case have to do with the comment I was replying to?
So, which would you have chosen?