I want to write my own Linked-list< T> and implement java.util.Collection< T>.
My problem is the warning: "The type parameter T is hiding the type T". that occures when I override the method public <T> T[] toArray(T[] arg0){}
Here's my code:
public class MyLinkedList<T> implements Serializable,Iterable<T>, Collection<T>
{
//some constructor here.
public <T> T[] toArray(T[] arg0) // I get that error here under the <T> declaration
{
return null;
}
...
// all other methods
...
}
(I know I can extend AbstractCollection class instead but that's not what I want to do).
Anybody have any idea how to solve this?
Should I change the parameter T in Collection< T> to be some other letter like so: Collection< E>
?