Due to type erasure, the JVM doesn't know at runtime that you have a Vector
of String
. The best it can do is create a 'raw' Vector. It can't guarantee for you that all Vector
s actually contain String
s. That's why you get a warning from your IDE.
One way to work around this, it cast it, as jgubby suggests. Another is to put a List
into your Vector
s, instead of an array.
But, more importantly, why can the array have only 3 items? Wouldn't it be better to create a class with three fields to put into your Vector
? With three items, that's not too much work, and you get the added bonus that you can give each of the three elements a helpful name, which should make your code a lot clearer.
Also, since Java 6, there exist a number of useful new synchronized List
implementations, which might perform better than Vector
, such as CopyOnWriteArrayList
, or wrap a regular List
in a Collections.synchronizedList
.