import java.util.ArrayList; import java.util.Map; public class StockTracker { Map151 positions; public StockTracker() { positions = new Map151<>(); } public void track(String filename) { ArrayList data = new ReadCSV().csvCollection(filename); System.out.println("trades read: " + data.size()); for (String[] datum : data) { int newamt = Integer.parseInt(datum[1]); Integer oldVal = positions.get(datum[0]); if (oldVal != null) newamt += oldVal; positions.put(datum[0], newamt); } } public String toString() { return positions.toString(); } public static void main(String[] args) { StockTracker st = new StockTracker(); st.track("bigtrades.csv"); System.out.println(st); } }