Driver code
public static void main ( String args [ ] ) { Node head = newNode ( 10 ) ; head . next = newNode ( 20 ) ; head . next . next = newNode ( 10 ) ; head . next . next . next = newNode ( 30 ) ; head . next . next . next . next = newNode ( 40 ) ; head . next . next . next . next . next = newNode ( 10 ) ; head . next . next . next . next . next . next = newNode ( 60 ) ; System . out . printf ( "Before moveToEnd(), the Linked list isNEW_LINE"); printList ( head ) ; int key = 10 ; moveToEnd ( head , key ) ; System . out . printf ( " After moveToEnd ( ) , the Linked list is "); printList ( head ) ; } }