I'm trying to make an array of vectors like this:
Vector<String>[] wordList = new Vector[29];
for (int i = 0; i < wordList.length; i++) {
wordList[i] = new Vector<String>(100);
}
But Java warns me that "new Vector[29]" violates type safety. How do I get rid of the the warning?
Update: I've tried:
wordList = new Vector<String>[29];
Of course, but this generates the error: Cannot create a generic array of Vector
Vector<String>[] wordList = (Vector<String>[])new Vector[29];
Consider using a List of List<String> instead of an array of Vectors, like so:
List<List<String>> wordList = new Vector<List<String>>();
This doesn't generate any warnings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With