private List < String > joinList ( final String head , final List < String > tail ) { return new AbstractList < String > ( ) { @ Override public String get ( int index ) { if ( index == 0 ) { return head ; } else { return tail . get ( index - 1 ) ; } } @ Override public int size ( ) { return tail . size ( ) + 1 ; } } ; }
Takes an elements and a list and returns a new list with both .