Added a method for inserting an object into an array.