CJCoding With Joseph
15per day
← Back to Question List

Select topics to narrow your question pool, then enable Random to jump to a random question matching your filters.

Topics:
Java Quiz #56

ObservableList and ListView

mediumJavaFX

After the "Add" button is clicked once, then the "Remove" button is clicked once, what does the ListView display?

📄 Code

1ObservableList<String> items = FXCollections.observableArrayList("Apple", "Banana");
2ListView<String> list = new ListView<>(items);
3 
4Button addBtn = new Button("Add");
5addBtn.setOnAction(e -> items.add("Cherry"));
6 
7Button removeBtn = new Button("Remove");
8removeBtn.setOnAction(e -> items.remove(0));