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]
# 1

> 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];

c0demonk3ya at 2007-7-29 16:03:38 > top of Java-index,Java Essentials,Java Programming...
# 2

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

shimritda at 2007-7-29 16:03:38 > top of Java-index,Java Essentials,Java Programming...
# 3

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>>()

c0demonk3ya at 2007-7-29 16:03:38 > top of Java-index,Java Essentials,Java Programming...
# 4

Hmmm for some reason it's adding in extra ">" where there shouldn't be ones

c0demonk3ya at 2007-7-29 16:03:38 > top of Java-index,Java Essentials,Java Programming...