How to convert an observable list to an array list? Java


I'm trying to get all the items in a table view and place them in an array list for further processing. This is what I'm trying to achieve but obviously it won't work.

ArrayList<Consultation> showing = consultationTable.getItems();
Ole V.V.

Nice and recommended solution:

List<Consultation> showing = provider.getItems();

Solution to use only if necessary:

    List<Consultation> consultations = provider.getItems();
    ArrayList<Consultation> showing;
    if (consultations instanceof ArrayList<?>) {
        showing = (ArrayList<Consultation>) consultations;
    } else {
        showing = new ArrayList<>(consultations);

If for some reason you need to use an ArrayList method that is not in the List or ObservableList interface (I cannot readily think of why), you may use the latter.

Collected from the Internet

Please contact javaer1[email protected] to delete if infringement.

edited at


Login to comment