I have a method to remove an object from the list, this is used to create a listView
so the object is removed using the index of the listview
item selected. But I want the method to work for several types of objects i.e., I have more than one listview
.
public void removeFromList(ListView<Label> listView, ArrayList<objects?> arrayList){
int minus = listView.getSelectionModel().getSelectedIndex();
arrayList.remove(minus);
listView.getItems().remove(minus);
}
Use the wildcard bound:
ArrayList<?> arrayList
This allows you to pass any ArrayList
to the method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With