• + 1 comment

    this code is similar to yours but it gives a null pointer exception.can you explain why?

    if(head==null){
        return;
    }
    else{
        head=head.next;
        ReversePrint(head);
        System.out.println(head.data);
    }