Here you can find the source of mergeList(List
public static Object mergeList(List<Object> list)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { public static Object mergeList(List<Object> list) { Object ret = null;/*from w ww .j av a 2 s . c o m*/ for (Object value : list) { ret = add(ret, value); } return ret; } public static Object add(Object oldValue, Object newValue) { if (oldValue == null) { return newValue; } if (oldValue instanceof Long) { if (newValue == null) { return (Long) oldValue; } else { return (Long) oldValue + (Long) newValue; } } else if (oldValue instanceof Double) { if (newValue == null) { return (Double) oldValue; } else { return (Double) oldValue + (Double) newValue; } } else { return null; } } }