Ask Question
6 June, 04:58

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. 6 June, 05:11
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers