← Back to Question List
Java Quiz #56
ObservableList and ListView
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);34Button addBtn = new Button("Add");5addBtn.setOnAction(e -> items.add("Cherry"));67Button removeBtn = new Button("Remove");8removeBtn.setOnAction(e -> items.remove(0));