title: delete object out of arraylist Java
body: <p>Here i have create a delete method that will search through the Object array and remove the selected object.  </p>
  
  <pre><code>public class DogList {
      private int numItems;
      private DogItem[] dogListArray;
      private int position;
      private String name;
  
      DogList () {
          numItems=0;
          position = 0;
          dogListArray = new DogItem[20]; 
      }
  
      DogList(String name) {
          this.name = name; 
      }
  
      public void deleteItem(DogList gi) {
          int i = 0; 
          while( (i &lt; numItems) &amp;&amp; (gi != dogListArray[i]) ) {
              i++; 
          }
  
          if(i == numItems) {
              // Throw exception if there is not matching Item
              throw new NoSuchElementException("That item does not exists"); 
          }
          int pos = i;
          while(pos &lt; numItems -1 ) {
              dogListArray[pos] = dogListArray[pos + 1]; 
              pos++; 
          }
          numItems --; 
      }
  </code></pre>
  
  <p>I cant wrap my head around why in the first while loop the <code>(gi != dogListArray[i])</code> is throwing an error:"Incompatible operand types DogList and DogItem"</p>
  
  <p>Any help would be wonderful.
  The code is pretty long so if you want to see any part i will edit and show what is needed. </p>