We got this method as homework assignment. There should be a way to make the method do less comparisons at runtime.
(the method finds the min and max of the array)
Any help would be appreciated.
Code:public void what()
{
int x = _arr[0];
int y = _arr[0];
for (int i=1; i<_arr.length; i++)
{
if (_arr[i] < x)
x = _arr[i];
else if (_arr[i] > y)
y = _arr[i];
}
System.out.println (x + " " + y);
}
