Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. public ListItem reverse_i() {
  2. ListItem curr = this;
  3. ListItem prev = null;
  4. while (curr != null) {
  5. // Store the next item in the list
  6. ListItem next = curr.next;
  7. // Set the current ListItem's next value to the previous ListItem
  8. curr.next = prev;
  9. // Set the previous equal to the current value
  10. prev = curr;
  11. // Move curr along
  12. curr = next;
  13. }
  14. return prev;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement