List.remove() oddities
From reddit’s r/java, a user observed that List.remove(Object) removes the first object whose equals() method returns true. Thus, if two objects have object equality with each other, but you wish to remove the second, you’re going to have to find it and return it with the indexed version of remove(int) instead of the remove(Object) call.yawkat observed that you can use Collection.removeIf() (which List inherits) and get...
Oct 23, 2025 — 1 minute(s) read