B
blue.striped.cat
Hello,
I am new to 1.5 and thus generics. I have read the generic tutorial and
a decent number of websites/newsgroup posts on the subject. But I still
cannot find a satisfactory solution to the following (as of now the
best I've got is an unchecked conversion warning)
The code below does not compile, but I think it shows to a human what I
want to accomplish. I can't seem to find the proper syntax and use of
generics to accomplish this without a warning. Any help and reasoning
why I need to do whatever the solution is would be great. Thanks.
public class MyClass {
private List<Foo>[] myFoos;
public MyClass() {
myFoos = new List<Foo>[5];
}
public void addFoo(int index, Foo foo) {
myFoos[index].add(foo);
}
}
I am new to 1.5 and thus generics. I have read the generic tutorial and
a decent number of websites/newsgroup posts on the subject. But I still
cannot find a satisfactory solution to the following (as of now the
best I've got is an unchecked conversion warning)
The code below does not compile, but I think it shows to a human what I
want to accomplish. I can't seem to find the proper syntax and use of
generics to accomplish this without a warning. Any help and reasoning
why I need to do whatever the solution is would be great. Thanks.
public class MyClass {
private List<Foo>[] myFoos;
public MyClass() {
myFoos = new List<Foo>[5];
}
public void addFoo(int index, Foo foo) {
myFoos[index].add(foo);
}
}