Testing out code to find the min and max element in an array. My code for finding the maximum works fine .. but my min prints "Minimum element in the array: 0". I probably have one little mistake that is throwing me off lol.
public void deleteMin() {
// set value for comparision starting from the beginning of the array
int arrayMin = arr[0];
for (int j = 0; j < nElems; j++) {
if (arr[j] < arrayMin) {
arrayMin = arr[j];
}
// insert delete functionality
}
System.out.println("Minimum element in the array: " + arrayMin);
}