### Question:
ListDouble implements ListNumber, CollectionDouble { public static ListDouble concatenate( final ListNumber... lists ) { int size = 0; for ( ListNumber l : lists ) { size += l.size(); } final int sizeCopy = size; return new ListDouble() { @Override public int size() { return sizeCopy; } @Override public double getDouble( int index ) { if ( index < 0 || index >= size() ) { throw new IndexOutOfBoundsException( "Index out of bounds: " + index + ", size: " + size() ); } int startIdx = 0; for ( ListNumber l : lists ) { int endIdx = startIdx + l.size()-1; if ( startIdx <= index && index <= endIdx ) { return l.getDouble( index - startIdx ); } startIdx += l.size(); } return 0; } }; }  @Override IteratorDouble iterator(); @Override float getFloat(int index); @Override long getLong(int index); @Override int getInt(int index); @Override short getShort(int index); @Override byte getByte(int index); @Override void setDouble(int index, double value); @Override void setFloat(int index, float value); @Override void setLong(int index, long value); @Override void setInt(int index, int value); @Override void setShort(int index, short value); @Override void setByte(int index, byte value); static ListDouble concatenate( final ListNumber... lists ); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void testConcatenation1() { ArrayDouble l1 = new ArrayDouble( new double[] {0, 1, 2, 3, 4} ); ArrayDouble l2 = new ArrayDouble( new double[] {5, 6, 7, 8, 9} ); ListDouble combined = ListDouble.concatenate( l1 , l2 ); for ( int i=0 ; i<9 ; i++ ) { assertThat( (int) combined.getDouble( i ) , equalTo( i ) ); } }
@Test public void testConcatenation3() { ArrayDouble[] lists = new ArrayDouble[ 10 ]; for ( int i=0 ; i<lists.length ; i++ ) { lists[ i ] = new ArrayDouble( new double[]{} ); } ListDouble concatenated = ListDouble.concatenate( lists ); assertThat( concatenated.size() , equalTo( 0 ) ); try { concatenated.getDouble( 0 ); assertTrue( false ); } catch ( Exception e ) { } }
@Test public void testConcatenation4() { ArrayDouble l1 = new ArrayDouble( new double[]{ 1 } ); ArrayDouble l2 = new ArrayDouble( new double[]{1, 2} ); ArrayDouble l3 = new ArrayDouble( new double[]{1, 2, 3} ); ArrayDouble l4 = new ArrayDouble( new double[]{1, 2, 3, 4} ); ArrayDouble l5 = new ArrayDouble( new double[]{1, 2, 3, 4, 5} ); ListDouble concatenated = ListDouble.concatenate( l1 , l2 , l3 , l4 , l5 ); double[] expValues = { 1 , 1 , 2 , 1 , 2 , 3 , 1 , 2 , 3 , 4 , 1 , 2 , 3 , 4 , 5 }; for ( int i=0 ; i<expValues.length ; i++ ) { assertThat( expValues[ i ] , equalTo( concatenated.getDouble( i ) ) ); } }