I think here we should first check if there is a next node before lost the reference on first object
https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/datastructures/hashmap/hashing/HashMap.java
/**
Linked list class - delete method with the following signature
*/
public void delete(int key) {
if (!isEmpty()) {
if (first.getKey() == key) {
first = null;
} else {
delete(first, key);
}
} else {
System.out.println("List is empty");
}
}