I need a little help. Here are the specs:
Create a method called findLargest, which takes an array of integers as an input parameter and returns the array index of the largest integer in the array. If there are positions that are tied for largest, the method should return the first index with a largest value.
Examples:
data:{25,11,15,25}
==> 0
data:{2,11,15,25}
==> 3
Here is the line of code given:
public int findLargest(int[] data){ }
This is what I have so far.
int index = 0;
int largest;
largest = data[0];
for(int i =0; i < index; i++)
if(largest < data[i])
{
largest = data[i];
return data[i];
}
Not sure where to go from here.