When you call remove(object o) on an arraylist, how does it compare objects?

ArrayList remove() relies on the objects implementation of the Equal method. If no implementation has been done then the object is removed by Object‘s implementation of Equals which indeed is the pointer comparison. From the documentation on ArrayList – More formally, removes the element with the lowest index i such that (o==null ? get(i)==null : … Read more

How to find the minimum value in an ArrayList, along with the index number? (Java)

You can use Collections.min and List.indexOf: int minIndex = list.indexOf(Collections.min(list)); If you want to traverse the list only once (the above may traverse it twice): public static <T extends Comparable<T>> int findMinIndex(final List<T> xs) { int minIndex; if (xs.isEmpty()) { minIndex = -1; } else { final ListIterator<T> itr = xs.listIterator(); T min = itr.next(); … Read more