Ask Question

Create a static 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.

+4
Answers (1)
  1. 18 April, 11:04
    0
    Public static int findlargest (int[] theArray)

    {

    int index = 0;

    int maxVal = 0;

    for (int i = 0; i < theArray. length; i++)

    {

    if (theArray[ i ] > maxVal)

    {

    maxVal = theArray[ i ];

    index = i;

    }

    }

    return (index);

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Create a static method called findlargest, which takes an array of integers as an input parameter and returns the array index of the ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers