Alexander Potochkin wrote:

but you can use the following workaround:

@SuppressWarnings("unchecked")
E[] array = (E[])new Object[10];

Consider this client code:

    JList<String> list = ...;
    String[] strs = list.getSelectedValues();

In that code you have a ClassCastException from Object[] to String[].

Unfortunately you can *not*, for obscure language reasons, even declare JList<E>.getSelectedValues as:

    public <T super E> T[] getSelectedValues()

So, I think if you want the method genericisted, it needs to be deprecated (or as near as we are allowed) and replaced. Although for my money, you're always better off going for a model and leaving the actual JComponent well alone.

Tom Hawtin

Reply via email to