Generics Java i Shadowing parametrów typu
Ten kod działa dobrze
<code>class Rule<T> { public <T>Rule(T t) { } public <T> void Foo(T t) { } } </code>Czy typ metody parametr zacienia parametr typu klasy?Czy podczas tworzenia obiektu używa on parametru typu klasy?
przykład
<code>Rule<String> r = new Rule<String>(); </code>
Czy to normalnie odnosi się do parametru typu klasy w sytuacji, gdy onenie konfliktować? Mam na myśli, gdy tylko klasa ma parametr type, a nie konstruktor, czy też szuka parametru typu w konstruktorze? Jeśli onirobić konflikt jak to się zmienia?
ZOBACZ PONIŻEJ DYSKUSJĘ
jeśli mam wywołanie funkcji
<code>x = <Type Parameter>method(); // this is a syntax error even inside the function or class ; I must place a this before it, why is this, and does everything still hold true. Why don't I need to prefix anything for the constructor call. Shouldn't Oracle fix this. </code>