Driver Code
public static void main ( String args [ ] ) { root = new Node ( 5 ) ; root . next = new Node ( 2 ) ; root . next . next = new Node ( 2 ) ; root . next . next . next = new Node ( 7 ) ; root . next . next . next . next = new Node ( 2 ) ; root . next . next . next . next . next = new Node ( 2 ) ; root . next . next . next . next . next . next = new Node ( 2 ) ; int key = 2 ; System . out . println ( " Linked ▁ List ▁ before ▁ operations ▁ : " ) ; display ( root ) ; System . out . println ( " Linked List after operations : "); root = keyToEnd ( root , key ) ; display ( root ) ; } }