Here you can find the source of difference(final List extends Object> minuend, final List extends Object> subtrahend)
public static List<Double> difference(final List<? extends Object> minuend, final List<? extends Object> subtrahend)
//package com.java2s; /******************************************************************************* * Copyright 2015/*from ww w.j a v a2 s .c om*/ * Ubiquitous Knowledge Processing (UKP) Lab * Technische Universit?t Darmstadt * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ import java.util.ArrayList; import java.util.List; public class Main { public static List<Double> difference(final List<? extends Object> minuend, final List<? extends Object> subtrahend) { final List<Double> result = new ArrayList<Double>(); for (int i = 0; i < minuend.size(); ++i) { final Object o1 = minuend.get(i); final Object o2 = subtrahend.get(i); if (areBothNumbers(o1, o2)) { subtract(result, o1, o2); } else { result.add(Double.NaN); } } return result; } private static boolean areBothNumbers(final Object o1, final Object o2) { return o1 instanceof Number && o2 instanceof Number; } private static void subtract(final List<Double> result, final Object o1, final Object o2) { final Number val1 = (Number) o1; final Number val2 = (Number) o2; result.add(val1.doubleValue() - val2.doubleValue()); } }