The implementation would be reasonably similar to code.
If you create 2 methods (let's be creative and call them min and max).
Min would work something like this (this should give an idea of the logic, not necessarily exactcode):
-
void min(int[] input)
-
{
-
int min =input[0];
-
int minIndex = 0;
-
for(int i=0; i<input.size; i++) // I can never remember whether Java likes length or size
-
{
-
if(input[i] < min)
-
{
-
min = input;
-
minIndex = i;
-
}
-
}
-
System.out.println("The minimum value was at index: " + minIndex);
-
}
-
The max method would be implemented in a similar way, and if you wanted you could return either the index or the actual value to the calling function