Chris Kimball wrote:When I know it, I'd like to put
Choices = new JComboBox<String>[N];
I should add, for completeness, that you can do what you want with:
choices = (JComboBox<String>) new JComboBox[N];[
but you will still get the warning about unchecked conversion.
You can remove that with something like:which would then allow you to use a native array; but TBH, I prefer Stevens' suggestion.
It's an unfortunate fact that arrays and generics just don't "mix" very well; but for 99.99% of the things you're ever likely to do, the overhead of an ArrayList - or indeed a List in general - is so miniscule that you'll probably never notice it.
And with a List, you get all sorts of other goodies like Iterators and sorts and contains() to play with, so my advice is to get used to using them ... for most stuff.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here