1]. DSA/1]. Data Structures/06]. Linked List/Java/_14)_Delete_Node_With_Given_Pointer_In_LinkedList.java
import java.util.*;
import java.io.*;
import java.lang.*;

class Node{
        int data;
        Node next;
        Node(int x){
            data=x;
            next=null;
        }
    }
  
class Test { 
    
    public static void main(String args[]) 
    { 
        Node head=new Node(10);
    	head.next=new Node(20);
    	Node ptr=new Node(30);
	    head.next.next=ptr;
    	head.next.next.next=new Node(40);
    	head.next.next.next.next=new Node(25);
    	printlist(head);
	    deleteNode(ptr);
    	printlist(head);
    } 
    
    static void deleteNode(Node ptr){
        Node temp=ptr.next;
        ptr.data=temp.data;
        ptr.next=temp.next;
    }
    
    public static void printlist(Node head){
        Node curr=head;
        while(curr!=null){
        System.out.print(curr.data+" ");
        curr=curr.next;
    }System.out.println();
    }
} 