title: Make one position in an array equal a new object
body: <p>How to make one position in an array equal a new object?</p>
  
  <pre><code>public SalesItem findItem(String itemCode){
  
      SalesItem[] item = new SalesItem();
      for (int i=0; i&lt;size; i++) {
  
          if(itemCode.equals(items[i].getItemCode())){
              if(items[i].getQuantity() &gt; 0) {
                  item = items[i];
                  items[i].setQuantity(items[i].getQuantity()-1);
              }
      }
   return item;
  }
  </code></pre>
  
  <p>I'm trying to find the position in the array contains the string "itemCode" and then use that position of the array to make it equal to the new item that i've declared so that i can then return the new item to be added to a shopping basket.</p>
  
  <p>I know I'm not doing something right with the SalesItem object, but I don't know what.</p>