Run Time Error on All Cases

I removed public modifier of LinkedList Class
My function is as follows
public void reverse(int k){
Stack stack=new Stack();
Node current=head;
Node prev=null;
while(current!=null) {
int count=0;
while(current!=null&&count<k) {
stack.push(current);
current=current.next;
count++;
}
while(stack.size()>0) {
if(prev==null) {
prev=stack.peek();
head=prev;
stack.pop();
}else {
prev.next=stack.peek();
prev=prev.next;
stack.pop();
}
}
}
prev.next=null;
}