Node p = root, n = null; while (p != null) { Node tmp = p.next; p.next = n; n = p; p = tmp; } root = n;