Here you can find the source of sumInColumns(ArrayList
static public ArrayList<String> sumInColumns(ArrayList<String> lines)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { static public ArrayList<String> sumInColumns(ArrayList<String> lines) { ArrayList<ArrayList<String>> valuesInColumns = valuesInColumns(lines); ArrayList<String> result = new ArrayList<String>(); for (int i = 0; i < valuesInColumns.size(); i++) { ArrayList<String> values = valuesInColumns.get(i); Double sum = 0.0;// w w w . java 2 s . com for (String value : values) { try { sum = sum + Double.parseDouble(value); } catch (Exception e) { sum = null; break; } } result.add(sum + ""); } return result; } static public ArrayList<ArrayList<String>> valuesInColumns( ArrayList<String> lines) { ArrayList<ArrayList<String>> valuesInColumns = new ArrayList<ArrayList<String>>(); for (int row = 0; row < lines.size(); row++) { String[] values = lines.get(row).replace("<,>", "<>") .split(","); for (int i = 0; i < values.length; i++) { if (valuesInColumns.size() <= i) { valuesInColumns.add(new ArrayList<String>()); } valuesInColumns.get(i).add(values[i]); } } return valuesInColumns; } }