Table of Contents


In order to find the location of the largest value of an unsorted array, you need to use the findMax method.


1. Assume the zeroth value of the array is the maximum.
2. Proceed through the array, checking if any value is less than the already assumed.
3. If a value less than the assumed is found, assume that location to be the new maximum.
4. Repeat steps 2 & 3 until you reach the end of the array.


public static int findMax(int[] x, int start){
    int max = start;
    for(int i = start + 1; i < x.length; i++){
        if (x[i] > x[max]){
            max = i;
    return max;
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License