public static ListDouble add ( final ListNumber data1 , final ListNumber data2 ) { if ( data1 . size ( ) != data2 . size ( ) ) throw new IllegalArgumentException ( "Can't sum ListNumbers of different size (" + data1 . size ( ) + " - " + data2 . size ( ) + ")" ) ; return new ListDouble ( ) { @ Override public double getDouble ( int index ) { return data1 . getDouble ( index ) + data2 . getDouble ( index ) ; } @ Override public int size ( ) { return data1 . size ( ) ; } } ; }
Returns a list where each element is the sum of the elements of the two lists at the same index . The lists have to match in size .