for(RoomBookingDTO r : bb.getBooking().getRoomBookings()) {
if(r.getLocalId() == bb.getCurrentRoomNumber()) {
System.out.println("kom hit");
bb.getBooking().getRoomBookings().remove(r);
}
}
当我尝试在运行remove方法之前和之后打印roomBookings
集时,该集包含完全相同的元素。因此,bb.getBooking().getRoomBookings().remove(r);
不起作用。我使用java.util.SortedSet
作为java.util.TreeSet
实现。为什么这不起作用的任何建议?
RoomBookingDTO roomBooking = createRoomBooking(request);
System.out.println("Before: " + bb.getBooking().getRoomBookings());
bb.getBooking().getRoomBookings().add(roomBooking);
System.out.println("Add: " + bb.getBooking().getRoomBookings());
bb.getBooking().getRoomBookings().remove(roomBooking);
System.out.println("After: " + bb.getBooking().getRoomBookings());