public ListNode reverseList(ListNode head){ ListNode newHead = new ListNode(); while(head!=null){ ListNode next = head.next; head.next = newHead.next; newHead.next = head; head = next; } return newHead.next; }