Java tutorial
//package com.java2s; //License from project: Apache License import android.util.SparseArray; import java.util.ArrayList; import java.util.Collections; public class Main { public static SparseArray<Float> compartmentsMaxValues(SparseArray<ArrayList<Float>> compartments) { SparseArray<Float> maxValues = new SparseArray<>(); for (int i = 0; i < compartments.size(); i++) { maxValues.put(i, Collections.max(compartments.get(i))); } return maxValues; } }