I'm attempting to create a function that allows you to pass in a ArrayList and return the max element. I have been unable to figure out a correct solution because of the data type being passed in is not primitive. I've also tried converting the ArrayList to ArrayList without success. Here is my (incorrect) code thus far:
public static void maxArrayListValue(ArrayList<int[]> arrayList) {
int maxArrayListValue = arrayList.get(0); // set first arrayList element as highest
for (int index=1; index < arrayList.size(); index++) { // cycle through each arrayList element
if (maxArrayListValue < arrayList.get(index)){ // if new element is > than old element
maxArrayListValue = arrayList.get(index); // replace with new maxValue
maxArrayListIndex = index; // record index of max element
}
}
return maxArrayListValue;
}
Any input would be apprecieated.