I'm new to java, so please excuse me if my explanation is poor but I have a list :
private LinkedList<User> users= new LinkedList<User>();
and a method removeUser:
private void removeUser() {
System.out.println("All Users: ");
viewUsers();
System.out.print("Please enter the ID of the user to be removed: ");
int choice = In.nextInt();
for (User user : users){
if (users.contains(choice)) {
users.remove(choice);
}
}
}
Now when I run the code it successfully prints out everything. Yet when I check the list contents, nothing has changed and I'm unsure of what I have done wrong with the removal part of the code.