How can i convert a DefaultListModel to a List ?
Arrays.asList(defaultListModel.toArray());
Description:
DefaultListModel
is not a subclass of List
. So it is not directly possible to pass that as a List
argument. Instead you can change the parameter type to ListModel<E>
. Such as:
computeSpending(ListModel<Subscription>)
Also,
If you must need to pass the DefaultListModel<Subscription>
into a List
, you can use:
List<Subscription> asList = Arrays.asList(defaultListModel.toArray());
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…