Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Find the array index of the smallest value

807601Apr 23 2008 — edited Apr 23 2008
I want to find the array index of the smallest value in a unsorted array. i am not allowed to sort the array.
public int find_index () {
for (int i = 0; i< 9; i++) {
            if (array[i] >  array[i+1]) {
               the_index = i+1;
            }
            else {
                the_index = i;
            }
        }
} 

return the_index;
}
what is wrong with above code
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 21 2008
Added on Apr 23 2008
6 comments
274 views