edit: I don't see how the other question answers mine. I already have an explicit cast (E[]) which the author of the other question doesn't have. I also tried something like seq1 = (Integer[]) iw.result(); but that doesn't work either.
I have the following code:
public class Something<E extends Comparable<E>> {
E[] seq;
public Something() {
seq = (E[]) new Object[100];
}
public E[] result() {
return sequence;
}
public static void main(String[] args) {
Something<Integer> iw = new Something<Integer>();
Integer[] seq1 = new Integer[100];
seq1 = iw.result();
}}
I get an errormessage in the way of: [Object can't be cast to [Comparable
So I change the Something-Constructor to:
seq = (E[]) new Comparable[100];
Now I get an errormessage in the way of: [Comparable can't be cast to [Integer
Is there any way to make the above code work? I know I would be better off working with Collections here, but I'm just curious what's wrong with my code.