[Solved] Search through an array in Java


I would prefere to use a collection of hospital objects instead of the array, but if this is not what you want you may use this:

int highestPriorityHospitalIndex(int[] a)
{
    for (int priority = 1; priority <= 7; priority++)
    {
        for (int i = 0; i < a.length; i++)
        {
            if (a[i] == priority && checkConditions(i))
            {
                return i;
            }
        }
    }
return -1;
}

solved Search through an array in Java