Array of Vectors
Perhaps this sounds a bit strange, but I think I have a pretty good reason for doing this. I intentionally want to make an array of vectors. Quite frankly, I don't like seeing warnings in my compiler output. So, I'm wondering what I can do about this. I also haven't tested this code to see if it actually works, but I don't see an issue with it.
Declaration:
Vector<Integer> uids =null;
Vector<BackupEntry>[] entries =null;
Initialization (just trust me that uids is initialized correctly):
// Okay we have a list of UIDs. Make the array
entries =new Vector[uids.size()];
// Init each one
for (int i = 0; i < entries.length; i++)
entries[i] =new Vector<BackupEntry>();
This code, however, results in the following warning (with Xlint:unchecked)
Compiling 30 source files to C:\wowiupdater\build\classes
C:\wowiupdater\src\wowiupdater\ReversionDialog.java:62: warning: [unchecked] unchecked conversion
found: java.util.Vector[]
required: java.util.Vector<wowiupdater.BackupEntry>[]
entries = new Vector[uids.size()];
1 warning
Now, I can seewhy it doesn't like this -- because the initialization code doesn't specify what it is a vector of. But, as you can see later in the code, we're certain to be making vectors of BackupEntrys. So I tried this:
entries =new Vector<BackupEntry>[uids.size()];
But that just results in the following complaint:
Compiling 30 source files to C:\wowiupdater\build\classes
C:\wowiupdater\src\wowiupdater\ReversionDialog.java:62: generic array creation
entries = new Vector<BackupEntry>[uids.size()];
1 error
BUILD FAILED (total time: 0 seconds)
So do I have any way around this warning, or do I just have to ignore it? (Or is there a better way I should be going about this?)
Regards,
-- Matt

