Iterate through the head1 to find the last node join the next of last node of head1 to the 1 st node of head2
while ( tail != null ) { if ( tail . next == null && head2 != null ) { tail . next = head2 ; break ; } tail = tail . next ; }