- Initialize a variable M to Integer.MIN_VALUE - Compare each element in the array to M - If the element is smaller than M, set M equal to that element's value.
When you get to the end of the array, M is the minimum value in the array. If you want the index of the minimum value, then just keep a second variable to hold the index, and set it each time you set M.
Or you can write a simple bubblesort and then just get the lowest value in element 0. It might actually be faster this way, even with a slower sort algorithm like bubblesort.
Using ArrayList defeats the purpose of learning how to program. Which is better?
A. Someone who learns Java and a good chunk of the API, might even get one or two of those certificates of dubious value.
B. Someone who learns how to program, understands the underlying contructs of library classes and computers themselves and can easily move to other languages and even write their own libraries and therefore can leverage existing libraries better then A.
Their achilles heel is the noogie! Give them noogies tiny ad!