title: How to search a string element in a class arraylist? (java)
body: <p>My question is that there is a method printPetInfoByName() searches the list of pets for every pet of a given name, and prints the pet’s information, using the toString() method.
  The arraylist is of type Pet and name is given from main method (i haven't coded it yet)
  I need to print info of a pet using toString() by searching arraylist. If the given name is present in list then it will print info.</p>
  
  <p>my code looks like this<img src="https://i.stack.imgur.com/zFWSn.jpg" alt="enter image description here"></p>
  
  <p>but it produces error > incompatible types: Pet cannot be converted to CharSequence for line 20
  if i write for(String search:list)
  then it gives error that Pet cannot be converted to String for line 18</p>