modifying search(), to perform linear search on a List
I am trying to Modify search() to perform the linear search on a list rather than an array. I was told the easiest way is to use a foreach and return the correct Person if found. If the correct Person is not found, it should return null as before. Can somebody help me with this? 

    private Person search(final int key) {
       for (int index = 0; index < n; ++index)
    if (key == theList[index].getId())    // Is this the right one?
        return theList[index];

      return null;      // apparently the requested object is not present
     } // search()
modifying search(), to perform linear search on a List
===

I am trying to Modify search() to perform the linear search on a list rather than an array. I was told the easiest way is to use a foreach and return the correct Person if found. If the correct Person is not found, it should return null as before. Can somebody help me with this? 

    private Person search(final int key) {
       for (int index = 0; index < n; ++index)
    if (key == theList[index].getId())    // Is this the right one?
        return theList[index];

      return null;      // apparently the requested object is not present
     } // search()