For this Question: Given a Node D of a linked list containing N unique nodes i.e the value at each node is unique, your task is to delete the given node from the list.

<b>Note</b>:- It is guaranteed that the given node is not the last node of the list and D is always present in the linked list<b>User Task:</b>
Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>deleteNode()</b> that takes the given node D as parameter.

Constraints:
1 <= N <= 1000
1 < = Node.data < = 100000
1 <= D <= Node.data

<b>Custom Input:-</b>
First line should contains number of Nodes N and the node val to be deleted, next line contains N space separated integers denoting the values of nodes.You don't need to print or return anything printing will be done by the driver code.Sample Input:-
List:- 2 - > 3 - > 4 - > 5
Given node:-3

Sample Output:-
2 - > 4 - > 5, I have written this Solution Code: 
public static void deleteNode(Node D) {

    if (D == null)
        return;
    else {
         Node prev=D;
        while (D.next != null) {
            D.val = D.next.val;
            prev = D;
            D = D.next;
        }
        prev.next= null;
    }
}
, In this Programming Language: Java, Now tell me if this Code is compilable or not?