Type safety warning
Hello,
i keep getting an anoying warning about a type safety, i have the following line in my code:
Vector<LogSample>[] clusters = new Vector[k];
(LogSample is a class of mine)
the warning:
Type safety: The expression of type Vector[] needs unchecked conversion to conform to Vector<LogSample>[]
if i'm changing it to:
Vector<LogSample>[] clusters = new Vector<LogSample>[k];
i'm getting the following compilation error:
Cannot create a generic array of Vector<LogSample>
any idea?
thanks
[580 byte] By [
shimritda] at [2007-11-27 11:25:18]

> Hello,
>
> i keep getting an anoying warning about a type
> safety, i have the following line in my code:
>
> Vector<LogSample>[] clusters = new Vector[k];
> (LogSample is a class of mine)
>
> the warning:
> Type safety: The expression of type Vector[] needs
> unchecked conversion to conform to
> Vector<LogSample>[]
>
> if i'm changing it to:
> Vector<LogSample>[] clusters = new
> Vector<LogSample>[k];
>
> i'm getting the following compilation error:
> Cannot create a generic array of Vector<LogSample>
>
> any idea?
>
> thanks
Declare your vector like so:
Vector<LogSample>[] clusters = new Vector<LogSample>[k];
thanks!
as i wrote in my first post, i already tried that and i'm getting a compilation error:
Cannot create a generic array of Vector<LogSample>
thanks
Doh! My mistake... that'll teach me not to read posts fully.
Why are you creating an array of Vectors? A Vector is a List already?
Rather than an array of Vectors try a Vector of Vectors
i.e.
Vector<Vector><LogSample>> vector = new Vector<Vector><LogSample>>()