title: how do i search lastNames saved in my arraylist in java?
body: <pre><code>public void searchLastName(String lastName)
  {
      int size = list.size();
  
      for(int i = 0 ; i &lt; size ; i++)
      {
          if(list.get(i).getLastName().equals(lastName))
              System.out.print(lastName+ " is located at " +i);
          else
              System.out.println("Cant find at loc:" +i);
  
      }
  }
  </code></pre>
  
  <p>is there any problem with this code?? i cant search the lastName.. please help me guys</p>
  
  <p>this is from class Person</p>
  
  <p><code>public String getLastName()
  {
  return lastName;
  }</code></p>