
Write a program(in java), if given a pointer to a node (not the tail node) in a singly linked list, delete that node from the linked list.

could you tell your question clearly?

could you tell your question clearly?

could you tell your question clearly?

could you tell your question clearly?

Given a pointer to a node(not the last node) in single linked list, how to delete this node..in java

?

Copy data from next node to this node and delete next node...
public void deleteANodeWithoutUsingHead(Node<T> node) {
if(node != null && node.getNext()!=null)
{
node.setData(node.getNext().getData());
node.setNext(node.getNext().getNext());
}
else{
throw new IllegalArgumentException("Given node cannot be null or last node.");
}
}