Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void reverse() {
- Node<Data> current = head; // 1
- Node<Data> previous = null; // 1
- while (current != null) { // 2
- Node<Data> next = current.next; // 3
- current.next = previous; // 4
- previous = current; // 5
- current = next; // 6
- }
- head = previous; // 7
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement